Skip to content
Sharp

Functions · interview question

What does a strong engineer do when reasoning through function extraction code?

Multiple choiceMediumchapter-2-curatedpremiumfunctionsfunction-extraction
python
def calculate_subtotal(unit_price: float, quantity: int) -> float:
    return unit_price * quantity


def shipping_fee(subtotal: float) -> float:
    return 0 if subtotal >= 100 else 6.50
Choose one answer
Answer and explanation

Correct answer

B. Narrate the data shape, the state changes, and the exact rule order step by step.

Why

Interviewers often use simple code to test whether you can reason through execution without bluffing.

Test yourself on Functions

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

Start free test
All Functions questions →