Codele / Programming basics
Giving and getting back values
A function can be a machine: you drop things in, it works on them, and one thing comes out. Watch the numbers travel in and the answer come back.
- Things you hand to a function are parameters. They go in the brackets.
- Inside the function, each parameter is a box with its own name.
- return sends one value back and ends the function.
- A call that returns a value can be stored: total = add_tip(bill, tip).
- Defining a function does nothing. The work happens only when it is called.
Loading the playable lesson…