Flow of Control · Class 11 · CBSE · Science Computer Science

What is printed by the following Python code? x = 3 while x < 10: x += 2 if x == 7: break print(x)

Practice question from Flow of Control (Class 11 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

easy · MCQ · Q-B220AD

What is printed by the following Python code? x = 3 while x < 10: x += 2 if x == 7: break print(x)

  1. A.5
  2. B.7Correct answer
  3. C.9
  4. D.10

Solution

The loop changes x from 3 to 5 and then to 7. When x becomes 7, the break statement immediately terminates the loop, so 7 is printed.

More from Flow of Control

All of Flow of Control

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed