Functions: package an idea you can call

A function is a named recipe with its own scratch space. When you call it, a fresh scope opens (watch the call stack appear), it does its work on the arguments you pass, and it hands a value back with return. Here is the same job — find the largest number — done four ways.

Find the largest number in a list — written straight, with no function.

Functions — the same work, inline execution-derived · CPython
variables
state after line 1 runs
variablevalue
nums[3,9,4]

noteNo function here — just the numbers, in the main program's own scope.

step 1 / 11

Click a line, drag the slider, or use the keys.

What you are looking at

Every value you see came from running each program under CPython's tracer — see how GlassBox stays honest.