PCEP Control Flow, Loops, Lists and Logic Practice Question
A developer needs to implement a loop that prints numbers from 10 down to 1. Which loop correctly achieves this?
⚠ Common exam trap
Python Institute often tests the exclusive nature of the stop argument in `range()`, leading candidates to forget that the stop value is never included in the sequence.
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
✓
for i in range(10, 0, -1): print(i)
`range(10, 0, -1)` generates numbers from 10 down to 1 inclusive. The start is 10, the stop is 0 (exclusive), and the step is -1, so the sequence is 10, 9, 8, ..., 1. This matches the requirement exactly.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
for i in range(10, 0, -1): print(i)
Why this is correct
range(10, 0, -1) starts at 10, stops before 0, and steps by -1, yielding 10 down to 1. The stop value is exclusive, so 0 is correctly omitted, matching the descending sequence the developer requires.
- ✗
for i in range(10, 0): print(i)
Why it's wrong here
range(10, 0) defaults to a step of +1, producing an empty sequence because 10 cannot reach 0 by incrementing, so nothing prints. It is tempting because the start and stop values look correct for a countdown, and it would be the right form when ascending from 10 up to (but excluding) 0.
- ✗
for i in reversed(range(1, 10)): print(i)
Why it's wrong here
reversed(range(1, 10)) iterates over 1 to 9 backwards, producing 9 down to 1 and omitting 10 entirely. It is tempting because reversed() genuinely yields descending order and the code runs without error, and it would be correct if the required sequence were 9 down to 1.
- ✗
for i in range(10, 1, -1): print(i)
Why it's wrong here
range(10, 1, -1) stops before 1, yielding 10 down to 2, so the final value 1 is never printed. It is tempting because the negative step correctly reverses direction and the syntax is valid, and it would be correct if the requirement were to print 10 down to 2.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.