Skip to content
Sharp

Functions · interview question

A bug appears around return values. What is the strongest first debugging move?

Multiple choiceMediumchapter-2-curatedpremiumfunctionsreturn-values
python
def discount_rate(is_vip: bool, subtotal: float) -> float:
    if is_vip and subtotal >= 100:
        return 0.15
    return 0.0
Choose one answer
Answer and explanation

Correct answer

D. Trace one concrete example, inspect the state transitions, and compare them to the intended rule before rewriting anything.

Why

That approach is reliable because it creates evidence. Mutating external state for everything makes the control flow harder to test and harder to explain.

Test yourself on Functions

A free test with instant, explained results. No account needed.

Start free test
All Functions questions →