Module 3~9 min
Parameters and Return Values
Functions become far more powerful when they can accept input and hand back a result. This lesson covers parameters and return values.
What You'll Learn
- What a parameter is
- What a return value is
- How they make functions flexible
Parameters: Giving Functions Input
A parameter is a value passed into a function when it's called, letting the same function behave differently depending on the input it receives.
Return Values: Getting a Result Back
A return value is the result a function hands back after it finishes running, which the rest of the program can then use.
Example
A function `add(a, b)` might take two parameters and return their sum -- calling `add(2, 3)` would return the value 5.
Key Concepts
ParameterReturn ValueFunction Input/Output
Key Takeaways
- A parameter is input passed into a function
- A return value is the result a function hands back
- Parameters and return values make functions flexible and reusable
Knowledge Check
What is a parameter?