Home » Programming Language (coding) » Python MCQ » What will be the output of the following Python code? i = 0 while i < 3: print(i) i += 1 else: print(0)

What will be the output of the following Python code? i = 0 while i < 3: print(i) i += 1 else: print(0)

Study the following program:

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

A. 0 1
B. 0 1 2
C. 0120
D. 0123

Correct Answer: Option C. 0 1 2 0 

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
23 + 8 =