PCEP Computer Programming and Python Fundamentals Practice Question
What does the following code output? for i in range(3): if i == 1: continue; print(i, end=' ')
⚠ Common exam trap
The PCEP exam often tests the continue statement by having candidates forget that it skips the rest of the loop body for the current iteration, leading them to incorrectly include the skipped value in the output.
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 2
The for loop iterates over range(3), which produces values 0, 1, and 2. When i equals 1, the continue statement skips the rest of the loop body for that iteration, so print(i, end=' ') is not executed for i=1. Thus, only 0 and 2 are printed, separated by a space, giving output '0 2'. Option B is correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
1
Why it's wrong here
Continue skips the print for i=1, so 1 is not printed.
- ✓
0 2
Why this is correct
i=1 is skipped.
- ✗
0 1 2
Why it's wrong here
Continue would not skip the print.
- ✗
0
Why it's wrong here
i=2 is also printed.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 498-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. What is the output of the following code? for i in range(1, 6): if i == 3: continue print(i, end=' ')
easy- A.1 2 3 4 5
- ✓ B.1 2 4 5
- C.1 2 4
- D.1 2 3 4
Why B: The code uses a for loop with range(1, 6) and a continue statement when i == 3. When i equals 3, the continue skips the print(i, end=' ') statement, so 3 is not printed. The loop iterates through 1, 2, 4, and 5, producing the output '1 2 4 5'.
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.