PCEP Control Flow, Loops, Lists and Logic Practice Question
A student grades system:
score = 85
if score >= 90:
grade = 'A' elif score >= 80: grade = 'B' elif score >= 70: grade = 'C' else: grade = 'F'
What grade is assigned?
⚠ Common exam trap
The trap here is that candidates might mistakenly think the last matching condition (score >= 70) applies, ignoring that the elif chain stops at the first True condition, leading them to pick 'C' instead of 'B'.
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
✓
B
The code uses a cascading if-elif-else structure. Since score is 85, the first condition (score >= 90) is False, so it moves to the elif score >= 80 condition, which is True, assigning grade = 'B'. The remaining elif and else are skipped, making 'B' the correct grade.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
C
Why it's wrong here
Score 85 satisfies the second condition (85 >= 80), so the 'B' branch executes and the elif chain terminates before reaching the 70 test. Choosing 'C' confuses the passing threshold with the assigned band; the 70 condition is never evaluated once an earlier branch matches.
- ✗
A
Why it's wrong here
Score 85 fails the first test (85 >= 90 is false), so the 'A' branch never executes. It is tempting because 85 is a high score and close to the 90 threshold, but Python evaluates each condition in order and assigns only the first matching branch, which here is 'B'.
- ✓
B
Why this is correct
With score 85, the first condition (>= 90) fails, so the elif chain evaluates sequentially. The second condition, score >= 80, is true, assigning grade = 'B'. Python stops at the first matching branch, so the remaining elif and else blocks are skipped entirely.
- ✗
F
Why it's wrong here
With score equal to 85, the first condition (>= 90) is false, but the second (>= 80) is true, so grade becomes 'B' and later branches are skipped. 'F' is tempting because it is the final else, but that branch only runs when every condition fails.
Go deeper
Related to this question
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 →
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.