Courseiva

PCEP Control Flow, Loops, Lists and Logic Practice Question

During a lab exercise, a student writes the following code to print a countdown from 3 down to 1, but the code enters an infinite loop and never stops. The code is:

count = 3

while count > 0:
    print(count)

Which change makes the loop terminate after printing 3, 2, and 1?

⚠ Common exam trap

The trap here is assuming the loop condition alone controls termination, when an unchanged loop variable leaves the condition permanently true.

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

✓

Add the statement count = count - 1 inside the loop body.

A while loop repeats as long as its condition stays true, so the counter must move toward the exit value on each pass. Reducing count by one each iteration makes the sequence 3, 2, 1 and then 0, at which point the condition fails and execution continues after the loop. Without such an update the condition never changes.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Add the statement count = count + 1 inside the loop body.

    Why it's wrong here

    Incrementing count makes the value grow further above zero on every pass, so the condition count > 0 remains true forever and the loop still never ends. It also never reaches 1 in a controlled way. The loop needs the counter to move toward zero, so adding to it is the opposite of what is required here.

  • ✓

    Add the statement count = count - 1 inside the loop body.

    Why this is correct

    Decrementing count each pass changes the value from 3 to 2 to 1, and after printing 1 it becomes 0, making count > 0 false and ending the loop. This is the standard counter-controlled pattern, where the loop variable must be updated inside the body so the condition eventually fails and the program continues.

  • ✗

    Change the condition to while count < 0:

    Why it's wrong here

    With count starting at 3, the condition count < 0 is false immediately, so the loop body never runs and nothing is printed at all. This eliminates the infinite loop but also eliminates the required countdown output. The original condition was correct; the missing piece was updating the counter inside the body.

  • ✗

    Add the statement count += 0 inside the loop body.

    Why it's wrong here

    Adding zero leaves count unchanged, so the value stays 3 on every iteration and the condition never becomes false. The loop keeps printing 3 indefinitely. A loop variable must actually change toward the terminating value; a no-op assignment does not satisfy the while condition's exit requirement.

About these practice questions

One of 482 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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

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.