Q53
What will be the output of the following Python code? i = 1 while True: if i%3 == 0: break print(i) i + = 1
A.
1 2 3
B.
error
AnswerC.
1 2
D.
none of the mentioned
Answer: Option B
Solution
Answer: Option B
Solution:
Explanation:The code starts with `i` initialized to 1.
The `while True` loop runs indefinitely until a `break` statement is encountered.
Inside the loop, the `if i%3 == 0:` condition checks if `i` is divisible by 3.
If `i` is divisible by 3, the `break` statement will terminate the loop.
If `i` is not divisible by 3, the value of `i` is printed.
Then, there's an error `i += 1` it should be not `i + = 1`.
So the correct answer is Option B: error