Courseiva
Question 330 of 498
Control Flow, Loops, Lists and LogiceasyMultiple ChoiceObjective-mapped

PCEP Control Flow, Loops, Lists and Logic Practice Question

A team is reviewing code that uses if-elif-else to classify a test score. They notice that for score 90, it prints 'B' instead of 'A'. Which of the following best explains the issue?

⚠ Common exam trap

Python Institute often tests the misconception that condition order is irrelevant in if-elif-else chains, tempting candidates to pick Option A, when in fact the sequential evaluation makes order crucial.

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

The condition for 'A' should be checked before 'B'

In an if-elif-else chain, the first matching condition is executed and the rest are skipped. If the condition for 'A' (e.g., score >= 90) is placed after the condition for 'B' (e.g., score >= 80), a score of 90 will match the 'B' condition first and never reach the 'A' condition. To fix this, the most restrictive condition (highest grade) must be checked first.

Answer analysis

Option-by-option breakdown

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

  • The order of conditions does not matter

    Why it's wrong here

    Order matters because only the first matching condition executes.

  • The elif condition should use >= instead of >

    Why it's wrong here

    Using >= would still print 'B' for 90 because it would be true before the 'A' condition.

  • The condition for 'A' should be checked before 'B'

    Why this is correct

    Correct: to print 'A' for scores >= 90, that condition must come first.

  • The code uses elif instead of else if

    Why it's wrong here

    elif is the correct Python syntax; it is not the cause of the issue.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on PCEP

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. 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?

easy
  • A.for score in scores: if score == 100: pass ...
  • B.for score in scores: if score == 100: break ... further processing
  • C.for i in range(len(scores)): if scores[i] == 100: exit() ...
  • D.while scores: score = scores.pop(); if score == 100: continue ...

Why B: 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.

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.