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

What is the output of the following Python code? for i in range(1, 6): if i % 2 == 0: continue print(i, end=" ")

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

medium · MCQ · Q-931778

What is the output of the following Python code? for i in range(1, 6): if i % 2 == 0: continue print(i, end=" ")

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

Solution

When i is even, continue skips the remaining statements in that iteration. Therefore, only the odd values 1, 3, and 5 are 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