AllInfoHub Logo

AllInfoHub – MCQ Practice

Control Structures – Multiple Choice Questions (MCQs)

  1. 25. What is the purpose of the 'continue' statement inside a nested loop?

    • A. To break out of the inner loop
    • B. To break out of the outer loop
    • C. To skip the current iteration of the inner loop
    • D. To skip the current iteration of the outer loop
  2. 26. What is the output of the following code? `x = True; if x: print('True')`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  3. 27. What will be the output of the following code? `y = False; if y: print('Yes') else: print('No')`?

    • A. Yes
    • B. No
    • C. Error
    • D. None
  4. 28. What will be the output of the following code? `z = 0; if z: print('Non-zero') else: print('Zero')`?

    • A. Non-zero
    • B. Zero
    • C. Error
    • D. None
  5. 29. What will be the output of the following code? `b = 5; while b > 2: print(b); b -= 1; else: print('Loop ended')`?

    • A. 5 4 3 Loop ended
    • B. 5 4 2003
    • C. Loop ended
    • D. Error
  6. 30. What is the output of the following code? `c = 0; if c > 0: print('Positive') elif c < 0: print('Negative') else: print('Zero')`?

    • A. Positive
    • B. Negative
    • C. Zero
    • D. Error
  7. 31. What is the output of the following code? `d = -1; if d > 0: print('Positive') elif d < 0: print('Negative') else: print('Zero')`?

    • A. Positive
    • B. Negative
    • C. Zero
    • D. Error
  8. 32. What is the output of the following code? `j = 5; if j % 2 == 0: print('Even') else: print('Odd')`?

    • A. Even
    • B. Odd
    • C. Error
    • D. None
  9. 33. What is the output of the following code? `k = 4; if k % 2 == 0: print('Even') else: print('Odd')`?

    • A. Even
    • B. Odd
    • C. Error
    • D. None
  10. 34. What is the output of the following code? `l = 1; while l < 5: print(l); if l == 3: break; l += 1`?

    • A. 1 2 2003
    • B. 1 2 3 4
    • C. 1 2
    • D. Error
  11. 35. What is the output of the following code? `m = [1, 2, 3, 4]; for num in m: if num % 2 == 0: continue; print(num)`?

    • A. 1 3
    • B. 2 4
    • C. 1 2 3 4
    • D. Error
  12. 36. What is the output of the following code? `n = 0; while n < 3: n += 1; if n == 2: continue; print(n)`?

    • A. 1 3
    • B. 1 2 2003
    • C. 1
    • D. Error