A function names a block of instructions. Calling it runs that block, allowing the same calculation with different inputs.
def minutes_to_seconds(minutes):
seconds = minutes * 60
return seconds
first = minutes_to_seconds(2)
print(first)
print(minutes_to_seconds(5))
120
300
def starts the definition. The name is followed by parentheses containing a parameter, minutes, and a colon. Indented lines form the body; four spaces per level are conventional. The definition creates the function; its body runs when called.
For the first call, Python evaluates 2, binds minutes to it for that call, calculates 120, and sends the result back via return. The caller binds first to that result. The second call has its own input and calculation.
2 → minutes_to_seconds → 120 → first
return ends the current call immediately. Code after it on that path does not run. A function can have no parameters: use empty parentheses in its definition and call.