What are actual parameters?

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!

Take the quiz →

Examples

  1. When you type print('Hello, World!'), 'Hello, World!' is an actual parameter being passed to the print function.
  2. Imagine a vending machine, when you put in $2 for a soda, that $2 is like an actual parameter for the 'buy drink' action.
  3. 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

Discussion

Recent activity