Courseiva

PCEP Control Flow, Loops, Lists and Logic Practice Question

A student is writing a program that stores the daily steps walked over a week in a list. She wants to determine whether any day had fewer than 1000 steps, and if so, report the first such day's index. Which approach correctly finds the index of the first value below 1000?

⚠ Common exam trap

The trap here is using a search that finds the smallest value or counts matches, when the requirement is specifically the first position that crosses a threshold.

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

✓

Use a for loop with range(len(steps)) and break when steps[i] < 1000, then use the loop variable i.

Finding the first element that satisfies a condition requires both the element and its position. Iterating over indices with range(len(steps)) provides the index, and breaking on the first match leaves the loop variable holding that index. Searching for the minimum, iterating over values, or counting qualifying days all answer different questions and cannot report the earliest qualifying index.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Use a while loop with a counter that increments only when the step count is below 1000.

    Why it's wrong here

    Incrementing a counter only on qualifying days counts how many days are below 1000, not where the first one occurs. The counter would also not correspond to list positions once earlier days fail the test. This approach answers a different question, namely the number of low-step days, and cannot identify the first qualifying index.

  • ✓

    Use a for loop with range(len(steps)) and break when steps[i] < 1000, then use the loop variable i.

    Why this is correct

    Iterating with range(len(steps)) gives access to each valid index. When the condition steps[i] < 1000 becomes true, break exits immediately, and the loop variable i still holds the index of that first qualifying day. This is the standard manual-search pattern and correctly reports the earliest index without scanning further elements.

  • ✗

    Use a for loop over the list elements and break when the element is below 1000, then print the element itself.

    Why it's wrong here

    Iterating directly over elements yields the step counts, not their positions. Breaking on the first value below 1000 and printing the element reports the number of steps, not the day's index, so it does not answer the question. To get the index while iterating values, enumerate would be needed, which this approach does not use.

  • ✗

    Use steps.index(min(steps)) to locate the day with the fewest steps.

    Why it's wrong here

    This finds the index of the minimum value in the list, which is the day with the fewest steps overall. That is not the same as the first day below 1000; the minimum could be far below 1000 and occur later in the week, while an earlier day also below 1000 would be ignored. The scenario asks for the first qualifying day, not the smallest value.

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.