Questions: Conditional Statements

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A function assigns letter grades using conditions in this order: if score >= 60 → 'D', elif score >= 70 → 'C', elif score >= 80 → 'B', elif score >= 90 → 'A'. What grade does a score of 95 receive?

A'A' — 95 satisfies the >= 90 condition
B'D' — 95 satisfies >= 60, which is the first condition checked, so the chain stops there
C'C' — elif conditions are checked in ascending order of threshold value
DNo grade — elif chains only run when all prior conditions are false
Question 2 Multiple Choice

A developer needs to print exactly one role-specific message for users who may be 'admin', 'editor', or 'viewer'. Which structure guarantees exactly one branch executes?

AThree separate if statements, one for each role
BAn if / elif / elif chain with one condition per role
CThree separate if statements each followed by a return statement
DA single if statement containing all three role checks nested inside it
Question 3 True / False

In a Python if/elif/elif chain, if the first condition evaluates to True, the interpreter still evaluates the remaining elif conditions to determine if any others also apply.

TTrue
FFalse
Question 4 True / False

Replacing an if/else structure with two separate if statements can change a program's behavior when both conditions could be true at the same time.

TTrue
FFalse
Question 5 Short Answer

What is the 'first match wins' rule in an elif chain, and why does the order of conditions matter for correctness?

Think about your answer, then reveal below.