MCQ Answer

<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)
Topic : Operators Expressions and Python Statements

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 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz