AllInfoHub Logo

AllInfoHub – MCQ Practice

Control Structures – Multiple Choice Questions (MCQs)

  1. 1. Which keyword is used to start an 'if' statement in Python?

    • A. if
    • B. then
    • C. switch
    • D. case
  2. 2. Which keyword is used for the 'else if' condition in Python?

    • A. elseif
    • B. elif
    • C. else if
    • D. if else
  3. 3. Which keyword is used for the 'else' condition in Python?

    • A. otherwise
    • B. else if
    • C. elif
    • D. else
  4. 4. What will be the output of the following code? `x = 5; if x > 3: print('Yes') else: print('No')`?

    • A. Yes
    • B. No
    • C. Error
    • D. None
  5. 5. What will be the output of the following code? `x = 2; if x > 3: print('A') elif x == 2: print('B') else: print('C')`?

    • A. A
    • B. B
    • C. C
    • D. Error
  6. 6. Which keyword is used to start a 'for' loop in Python?

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

    • A. range()
    • B. len()
    • C. enumerate()
    • D. zip()
  8. 8. 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
  9. 9. Which keyword is used to start a 'while' loop in Python?

    • A. while
    • B. loop
    • C. for
    • D. do
  10. 10. 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
  11. 11. Which keyword is used to exit a loop prematurely in Python?

    • A. break
    • B. exit
    • C. continue
    • D. stop
  12. 12. 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