nerdexam
Python_Institute

PCEP-30-02 · Question #336

Which one of the lines should you put in the snippet below to match the expected output? Expected output: 1245 Code: c = 0 while c < 5: c = c + 1 if c == 3: # enter code here print(c, end="")

The correct answer is B. continue. Option B (continue) is correct because it tells Python to skip the rest of the current loop iteration and jump back to the while condition check - so when c == 3, the print(c) line is never reached, and the loop continues with c = 4 and c = 5, producing 1245. Why the…

Question

Which one of the lines should you put in the snippet below to match the expected output? Expected output: 1245 Code: c = 0 while c < 5: c = c + 1 if c == 3:

enter code here

print(c, end="")

Options

  • Aexit
  • Bcontinue
  • Cprint()
  • Dbreak

How the community answered

(32 responses)
  • A
    9% (3)
  • B
    84% (27)
  • C
    3% (1)
  • D
    3% (1)

Explanation

Option B (continue) is correct because it tells Python to skip the rest of the current loop iteration and jump back to the while condition check - so when c == 3, the print(c) line is never reached, and the loop continues with c = 4 and c = 5, producing 1245.

Why the distractors fail:

  • A (exit) terminates the entire program immediately, so the output would be just 12 before the program stops.
  • C (print()) doesn't skip anything - it would print an extra blank line and then still execute print(c), adding 3 to the output.
  • D (break) exits the while loop entirely when c == 3, cutting the output short to just 12.

Memory tip: Think of continue as "skip this one and continue on" - it skips forward to the next iteration. Think of break as "break out" - it smashes through the loop wall and exits completely. When you see a question asking to skip a value while the loop keeps going, continue is almost always the answer.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice