Actual parameters are the values you give to a recipe when you’re cooking.
Imagine you have a recipe for chocolate chip cookies that says: “Put 2 cups of flour and 1 cup of sugar into the bowl.” The recipe is like a function in programming, and the amounts of flour and sugar are like actual parameters, they're what you use to make the cookie.
Now imagine you’re making cookies for your friends. You might say: “Let’s put 3 cups of flour and 1½ cups of sugar this time.” The 3 cups of flour and 1½ cups of sugar are still actual parameters, but they’ve changed, just like how a function can use different values each time it runs.
When You Make Different Cookies
If you change the amounts of flour or sugar, your cookies might be bigger or tastier. That’s just like how changing actual parameters affects what happens inside a function. The recipe (the function) stays the same, but the ingredients (the actual parameters) can vary, and that changes the final result!
Examples
- Imagine a vending machine, when you put in $2 for a soda, that $2 is like an actual parameter for the 'buy drink' action.
- If you tell your friend 'I will bring 3 apples', then 3 is an actual parameter of the 'bring fruit' task.
Ask a question
See also
- What is Continuation-passing style (CPS)?
- What are decorators?
- How Does 6 Coding Concepts for Absolute Beginners Work?
- How Does 6 Coding Concepts You MUST Know For Beginners Work?
- How do computers read code?