Control Structures – Multiple Choice Questions (MCQs)
-
-
26. What is the output of the following code? `x = True; if x: print('True')`?
-
27. What will be the output of the following code? `y = False; if y: print('Yes') else: print('No')`?
-
28. What will be the output of the following code? `z = 0; if z: print('Non-zero') else: print('Zero')`?
-
29. What will be the output of the following code? `b = 5; while b > 2: print(b); b -= 1; else: print('Loop ended')`?
-
30. What is the output of the following code? `c = 0; if c > 0: print('Positive') elif c < 0: print('Negative') else: print('Zero')`?
-
31. What is the output of the following code? `d = -1; if d > 0: print('Positive') elif d < 0: print('Negative') else: print('Zero')`?
-
32. What is the output of the following code? `j = 5; if j % 2 == 0: print('Even') else: print('Odd')`?
-
33. What is the output of the following code? `k = 4; if k % 2 == 0: print('Even') else: print('Odd')`?
-
34. What is the output of the following code? `l = 1; while l < 5: print(l); if l == 3: break; l += 1`?
-
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)`?
-
36. What is the output of the following code? `n = 0; while n < 3: n += 1; if n == 2: continue; print(n)`?