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; 3:<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;">else:<br></span><span style="font-size: 14px;">&nbsp; &nbsp; print(0)</span></pre><div><br></div>

What will be the output of the following Python code?

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


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

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

A. 0 1 2 3 0

B. 0 1 2 0

C. 0 1 2

D. error एरर




Correct Answer is :

B. 0 1 2 0



Explanation
The else part is executed when the condition in the while statement is false.
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