Drag steps to the numbered slots on the right, or tap a step then tap a slot.
PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Order the steps to write a for loop that iterates over a range of numbers.
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
Start with 'for', then variable name, then 'in', then range() with start, stop, step, then colon, then indented loop body
The correct order is to write 'for', then the loop variable, then 'in', then the range() function with appropriate arguments, then a colon, and finally an indented block containing the statements to repeat. This structure defines a for loop that iterates over a sequence generated by range().
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Start with 'for', then variable name, then 'in', then range() with start, stop, step, then colon, then indented loop body
Why this is correct
This follows the correct syntax: for variable in range(...): followed by an indented block.
- ✗
Start with range(), then 'for', then variable name, then 'in', then colon, then indented loop body
Why it's wrong here
range() cannot be placed before the 'for' keyword; the statement must begin with 'for'.
- ✗
Start with 'for', then variable name, then colon, then 'in', then range(), then indented loop body
Why it's wrong here
The colon must come after the complete condition (for variable in range(...)), not before 'in'.
- ✗
Start with 'for', then 'in', then variable name, then range(), then colon, then indented loop body
Why it's wrong here
The word 'in' must come after the variable name, not before it.
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 →
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.