Practice question · Put in order
Order the execution when Python runs: result = round(abs(-2.7))
- Call round, producing 3
- Bind the name result to 3
- Call abs, producing 2.7
- Evaluate the literal −2.7
Hints
- Nested calls evaluate from the inside out.
- Assignment happens last, the right side must be fully computed before the name is bound.
Show the answer
- Evaluate the literal −2.7
- Call abs, producing 2.7
- Call round, producing 3
- Bind the name result to 3
Why
Composition runs inside-out: innermost value, inner call, outer call, then the assignment. Reading nested code as a pipeline of values is the fastest way to trace what any expression does.
Practise Functions and modular decomposition
The app has 11 more questions on this lesson, and keeps your place in the course. Physics I is free to start.