Home → Resource

10th – Computer Science – Chapter 3 – Introduction to Python Programming

MCQs

  1. What is the output of print(“Hello” + “ “ + “World”)?
    a) HelloWorld b) Hello World c) Hello+World d) Error
  2. What type of value does the input() function return?
    a) Integer b) Float c) String d) Boolean
  3. Which of the following is NOT a step in the basic programming process?
    a) Write Code b) Compile/Interpret c) Execute d) Ignore Errors
  4. Which operator has the highest precedence in Python?
    a) Addition (+) b) Multiplication (*) c) Exponentiation (**) d) Parentheses ()
  5. Which of the following is a comparison operator in Python?
    a) += b) == c) ** d) //
  6. What is the result of 10 % 3 in Python?
    a) 3 b) 3.33 c) 1 d) 0
  7. What does floor division // return?
    a) The remainder b) The integer part of the quotient c) A float always d) The product
  8. What is the output of print(10 // 3)?
    a) 3.333 b) 3 c) 1 d) 4
  9. What does the logical ‘not’ operator in Python return?
    a) The sum of two values b) The opposite boolean value c) A comparison result d) A string
  10. After parentheses, which operator has the highest precedence in Python?
    a) Addition + b) Multiplication * c) Exponentiation ** d) Modulus %
  11. Python comments begin with # and are:
    a) Executed as code b) Ignored by the interpreter c) Stored in memory d) Printed automatically
  12. Which Python data type is used to store True or False?
    a) Integer b) Float c) String d) Boolean
  13. What is the output of the following code? age = 25; print(“ Age : “, age)
    a) Age: 25 b) 25 c) Age d) age
  14. What is the result of 5 > 3 and 2 < 1?
    a) True b) False c) Error d) None
  15. The str() function converts a value into which type?
    a) Integer b) String c) Float d) Boolean
  16. Which of the following is NOT a valid comparison operator in Python?
    a) >= b) != c) => d) ==
  17. PyCharm, VS Code, and IDLE are examples of which of the following?
    a) IDEs (Integrated Development Environments) b) Web browsers c) Databases d) Operating systems
  18. What is an f-string in Python used for?
    a) Formatting floating-point numbers only b) Embedding variables/expressions inside a string (string interpolation) c) Creating new files d) Importing libraries
  19. Google Colab is a cloud-based Python environment, which means:
    a) No installation is needed b) It requires installation c) It only works offline d) It requires a USB drive
  20. Which of the following is a valid Python variable name?
    a) 2myVar b) my-var c) my_var d) my var
  21. Which symbol is used to write comments in Python?
    a) // b) /* c) # d) —
  22. Python is called a versatile language, which means that it:
    a) Only works on one platform b) Is very slow c) Can only be used for games d) Applies to many different fields
  23. Which function converts a string into an integer?
    a) str() b) int() c) float() d) input()
  24. From which website can Python be downloaded?
    a) python.org b) python.com c) code.python.net d) download.pyin
  25. Exponentiation ** in Python is right-associative, so what does 2 ** 3 ** 2 equal?
    a) 64 b) 512 c) 36 d) 8
  26. What should you do while installing Python so that it can be run from the command line more easily?
    a) Uncheck “Add Python to PATH” b) Choose a different IDE c) Check “Add Python to PATH” d) Install only the IDE
  27. What is the output of print(type(3.14))?
    a) <class ‘int’> b) <class ‘str’> c) <class ‘bool’> d) <class ‘float’>
  28. What does the /= operator do in Python?
    a) Compares two values b) Multiplies and assigns c) Adds and assigns d) Divides and assigns the result
  29. What is the function of the += operator?
    a) Adds two numbers b) Compares values c) Adds and assigns d) Multiplies values
  30. In what form does input() in Python always return data?
    a) Integer b) Float c) String d) Boolean

Short Questions

(i) What are the three logical operators in Python?
(ii) What is the difference between / (division) and // (floor division)?
(iii) What does the % operator do in Python? Give an example.
(iv) What is string interpolation using f-strings in Python? Give an example.
(v) Write the PEMDAS operator precedence order in Python.
(vi) What is the result of True and False in Python?
(vii) What is the purpose of the print() statement in Python?
(viii) What are the four main Python data types? Give one example of each.
(ix) What is the float() function used for?
(x) Discuss three basic data types in Python.
(xi) How do you convert a string input to an integer in Python? Write code.
(xii) What is Python, and name three fields where it is used?
(xiii) What are logical operators, and name all three?
(xiv) What is an IDE? Name three Python IDEs from the chapter.
(xv) How do you display multiple values with one print statement in Python?
(xvi) What is operator precedence? Give an example.
(xvii) What is the difference between = (assignment) and == (comparison)?
(xviii) What does exponentiation ** do in Python? Give an example.
(xix) How do you get user input in Python?
(xx) Write any three main rules for naming variables in Python.
(xxi) Give one example each of an arithmetic, comparison, and assignment operator.
(xxii) What are three rules for naming variables in Python?
(xxiii) How does the if statement differ from the if-else statement?
(xxiv) What is Google Colab, and what is its main advantage?
(xxv) Why are comments important in programming?
(xxvi) What is the difference between float and integer data types?
(xxvii) What happens if you try to add a string and an integer in Python without converting?
(xxviii) Describe the difference between integer and float data types in Python.
(xxix) Why must ‘Add Python to PATH’ be checked during installation?
(xxx) What is the purpose of comments in Python code?

Long Questions

  1. What are arithmetic operators in Python? Provide examples of each operator and explain when you would use them.
  2. Write a program in Python that will take a name from the user and display a greeting message to the given name.
  3. What are the basic data types in Python? Explain integers, floats, strings, and Booleans with examples.
  4. Explain the input() and print() functions with examples.
  5. Write a program in Python that takes five numbers from the user and displays their average.
  6. Write a program in Python that takes two numbers from the user and displays their sum.
  7. Solve the following expressions: a) 8 + 3 * 4 – 2 ** 2 b) 20 % 7 * 3 + 10 // 3 c) 2 * 3 ** 2 % 4 + 10 – 6 / 2
  8. Explain how comparison and logical operators work together in conditional statements. Provide a practical example.

Answer Key

  1. b) Hello World
  2. c) String
  3. d) Ignore Errors
  4. d) Parentheses ()
  5. b) ==
  6. c) 1
  7. b) The integer part of the quotient
  8. b) 3
  9. b) The opposite boolean value
  10. c) Exponentiation **
  11. b) Ignored by the interpreter
  12. d) Boolean
  13. a) Age: 25
  14. b) False
  15. b) String
  16. c) =>
  17. a) IDEs (Integrated Development Environments)
  18. b) Embedding variables/expressions inside a string (string interpolation)
  19. a) No installation is needed
  20. c) my_var
  21. c) #
  22. d) Applies to many different fields
  23. b) int()
  24. a) python.org
  25. b) 512
  26. c) Check “Add Python to PATH”
  27. d) <class ‘float’>
  28. d) Divides and assigns the result
  29. c) Adds and assigns
  30. c) String

Leave a Reply

Your email address will not be published. Required fields are marked *