AllInfoHub Logo

AllInfoHub – MCQ Practice

Control Structures – Multiple Choice Questions (MCQs)

  1. 37. What is the output of the following code? `q = 'hello'; for char in q: if char == 'l': break; print(char)`?

    • A. h e
    • B. h e l
    • C. hello
    • D. Error
  2. 38. What is the output of the following code? `r = 'world'; for char in r: if char == 'o': continue; print(char)`?

    • A. w r l d
    • B. world
    • C. w r ld
    • D. Error
  3. 39. What is the output of the following code? `u = 5; if u > 10: print('A') elif u > 3: print('B') elif u > 0: print('C') else: print('D')`?

    • A. A
    • B. B
    • C. C
    • D. D
  4. 40. What is the output of the following code? `v = -2; if v > 10: print('A') elif v > 3: print('B') elif v > 0: print('C') else: print('D')`?

    • A. A
    • B. B
    • C. C
    • D. D
  5. 41. What is the output of the following code? `w = 0; if w > 10: print('A') elif w > 3: print('B') elif w > 0: print('C') else: print('D')`?

    • A. A
    • B. B
    • C. C
    • D. D
  6. 42. What is the output of the following code? `y = [1, 2, 3]; for i in range(len(y)): if y[i] == 2: break; print(y[i])`?

    • A. 1
    • B. 1 2
    • C. 1 3
    • D. Error
  7. 43. What is the output of the following code? `z = [1, 2, 3]; for i in range(len(z)): if y[i] == 2: continue; print(z[i])`?

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