Courseiva
Control Flow, Loops, Lists and LogicmediumMultiple ChoiceObjective-mapped

PCEP Control Flow, Loops, Lists and Logic Practice Question

Exhibit

Refer to the exhibit.

for i in range(5):
    if i == 3:
        continue
    print(i, end=' ')

What is the output of the code?

⚠ Common exam trap

Python Institute often tests the interaction between break and loop iteration order, where candidates mistakenly think break skips only the current iteration (like continue) or that the loop continues after the break condition is met.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

0 1 2 4

The code uses a for loop with range(5) to iterate over numbers 0 through 4. Inside the loop, an if statement checks if the current number equals 3; if true, the continue statement skips the remainder of the current iteration and moves to the next iteration. Therefore, when i is 3, the print(i) statement is skipped, but the loop continues with i=4, printing 4. Thus, the output is '0 1 2 4' (each on a new line). Option C correctly lists the printed values as 0, 1, 2, and 4.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • No output

    Why it's wrong here

    Prints for i=0,1,2,4.

  • 0 1 2 3 4

    Why it's wrong here

    Continue skips 3.

  • 0 1 2 4

    Why this is correct

    Correct: 3 is skipped.

  • 0 1 2 4 5

    Why it's wrong here

    Range ends at 4.

About these practice questions

One of 498 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.