Report Bug
Qus :

What will be the output of the following Python code?

i = 2
while True:
    if i%3 == 0:
        break
    print(i)
    i += 2

Qus

निम्नलिखित Python कोड का आउटपुट क्या होगा?

i = 2
while True:
    if i%3 == 0:
        break
    print(i)
    i += 2


A. 2 4 6 8 10 …
B. 2 4
C. 2 3
D. error


Solution
B. 2 4



Explanation
The numbers 2 and 4 are printed. The next value of i is 6 which is divisible by 3 and hence control exits the loop.



Report Bug