Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

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)
a) 0 1 2 3 0
b) 0 1 2 0
c) 0 1 2
d) error

Answer: b
Explanation: The else part is executed when the condition in the while statement is false.

Join The Discussion