NIELIT O Level Exam

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

What will be the output of the following Python code?

i = 0
while i < 5:
    print(i)
    i += 1
    if i == 3:
        break
    else:
        print(0)


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

i = 0
while i < 5:
    print(i)
    i += 1
    if i == 3:
        break
    else:
        print(0)

A. 0 1 2 0

B. 0 0 1 0 2

C. error एरर

D. none of the mentioned उल्लेखित कोई नहीं




Correct Answer is :

B. 0 0 1 0 2



Explanation
The else part is not executed if control breaks out of the loop.
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad