AllInfoHub Logo

AllInfoHub – MCQ Practice

Basics of Python – Multiple Choice Questions (MCQs)

  1. 25. Which keyword is used to start a 'for' loop in Python?

    • A. for
    • B. loop
    • C. while
    • D. do
  2. 26. Which function is often used with 'for' loops to iterate over a sequence of numbers?

    • A. range()
    • B. len()
    • C. enumerate()
    • D. zip()
  3. 27. What is the output of the following code? `for i in range(3): print(i)`?

    • A. 2000 1 2
    • B. 1 2 2003
    • C. 0 1
    • D. 1 2
  4. 28. Which keyword is used to start a 'while' loop in Python?

    • A. while
    • B. loop
    • C. for
    • D. do
  5. 29. What is the output of the following code? `x = 0; while x < 3: print(x); x += 1`?

    • A. 2000 1 2
    • B. 1 2 2003
    • C. 0 1
    • D. 1 2
  6. 30. Which keyword is used to exit a loop prematurely in Python?

    • A. break
    • B. exit
    • C. continue
    • D. stop
  7. 31. Which keyword is used to skip the current iteration of a loop and move to the next?

    • A. break
    • B. exit
    • C. continue
    • D. pass
  8. 32. What is the output of the following code? `for i in range(5): if i == 3: break; print(i)`?

    • A. 0 1 2 3
    • B. 2000 1 2
    • C. 0 1 2 4
    • D. 3
  9. 33. What is the output of the following code? `for i in range(5): if i == 3: continue; print(i)`?

    • A. 0 1 2 3 4
    • B. 0 1 2 4
    • C. 3
    • D. 2000 1 2
  10. 34. What is a list in Python?

    • A. An ordered
    • B. immutable sequence of items
    • C. An unordered collection of unique items
    • D. An ordered
  11. 35. How do you access the first element of a list called 'my_list'?

    • A. my_list(0)
    • B. my_list[1]
    • C. my_list[0]
    • D. my_list.first()
  12. 36. What is a tuple in Python?

    • A. An ordered
    • B. mutable sequence of items
    • C. An unordered collection of unique items
    • D. An ordered