Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (2.2k points)

i = 0

while i < 5:

    print(i)

    i += 1

    if i == 3:

        break

else:

    print(0)

A) 0 1 2 0

B) 0 1 2

C) error

D) none of the mentioned

1 Answer

0 votes
by (3.9k points)

The correct answer to the question “What will be the output of the following Python code” is option (B). 0 1 2. Because there is a break control statement, in the script, so else statement won’t be executed. If you wish to learn Python, then check out the Python certification course, from Intellipaat. And also check out the Python Programming video made by our expert team to get your fundamentals correct.

Browse Categories

...