← Python Programming for Beginners

Click “Download PDF”, then choose “Save as PDF” as the printer.

VJ Classes

MCQs with answers

Python Programming for Beginners

1. Which symbol starts a comment in Python?

  1. A. //
  2. B. #
  3. C. /*
  4. D. --

2. Which data type does Python give to the value 3.0?

  1. A. float
  2. B. int
  3. C. str
  4. D. double

3. Which keyword defines a function in Python?

  1. A. function
  2. B. define
  3. C. fun
  4. D. def

4. What does print(f"{7 / 2:.2f}") display?

  1. A. 3
  2. B. 3.5
  3. C. 3.50
  4. D. 3.500

5. After total = 0 and then for n in range(1, 5): total += n, what is the value of total?

  1. A. 15
  2. B. 10
  3. C. 4
  4. D. 5

6. Which statement about tuples is true?

  1. A. Tuples can grow with append()
  2. B. Tuples cannot contain repeated values
  3. C. Tuples are written in square brackets
  4. D. The items of a tuple cannot be changed after it is created

7. What does len(set([3, 1, 3, 2, 1])) return?

  1. A. 5
  2. B. 2
  3. C. 3
  4. D. 1

8. In a method of a class, what does self refer to?

  1. A. The particular object on which the method was called
  2. B. The class itself, shared by all objects
  3. C. The file in which the class is saved
  4. D. The value that the method returns

9. count = 0, then while count < 5: print(count), with nothing else inside the loop. What happens when this runs?

  1. A. It prints 0 to 4 and stops
  2. B. It prints nothing
  3. C. It prints 0 again and again without stopping
  4. D. It raises an error at once

10. If d = {'a': 1}, which expression gives 0 instead of raising an error for the missing key 'b'?

  1. A. d['b']
  2. B. d.get('b', 0)
  3. C. d.find('b')
  4. D. d['b'] or 0

Answer key

© 2026 VJ Classes · vjclasses.in