MCQ Answer

<p>What will be the output of the following Python code?</p><pre><span style="font-size: 14px;">i = 2<br></span><span style="font-size: 14px;">while True:<br></span><span style="font-size: 14px;">&nbsp; &nbsp; if i%3 == 0:<br></span><span style="font-size: 14px;">&nbsp; &nbsp; &nbsp; &nbsp; break<br></span><span style="font-size: 14px;">&nbsp; &nbsp; print(i)<br></span><span style="font-size: 14px;">&nbsp; &nbsp; i += 2</span></pre>

What will be the output of the following Python code?

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


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

i = 2
while True:
    if i%3 == 0:
        break
    print(i)
    i += 2
Topic : Operators Expressions and Python Statements

A. 2 4 6 8 10 …

B. 2 4

C. 2 3

D. error एरर




Correct Answer is :

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.
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad