Courseiva
Control Flow, Loops, Lists and LogiceasyMultiple ChoiceObjective-mapped

PCEP Control Flow, Loops, Lists and Logic Practice Question

A junior developer needs to write code that processes a list of student scores and stops processing when a score of 100 is encountered, as that score represents a perfect score that should be treated separately. Which loop construct is most appropriate?

⚠ Common exam trap

Python Institute often tests the distinction between `break`, `continue`, and `pass` in loops, and the trap here is that candidates may confuse `continue` (which skips only the current iteration) with `break` (which exits the loop entirely), leading them to choose option D incorrectly.

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 score in scores: if score == 100: break ... further processing

The `break` statement immediately exits the loop when a score of 100 is encountered, which matches the requirement to stop processing further scores. The `for` loop iterates over the list naturally, and the `if` condition checks for the perfect score, making this the most straightforward and efficient construct for this scenario.

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 score in scores: if score == 100: pass ...

    Why it's wrong here

    pass does nothing; loop continues.

  • for score in scores: if score == 100: break ... further processing

    Why this is correct

    Correct; break stops the loop.

  • for i in range(len(scores)): if scores[i] == 100: exit() ...

    Why it's wrong here

    exit() terminates the program, not just the loop.

  • while scores: score = scores.pop(); if score == 100: continue ...

    Why it's wrong here

    continue skips the perfect score but does not stop processing.

About these practice questions

One of 498 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 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.