Parameters Examples in CS Thinking
Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Parameters.
This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.
Concept Recap
Named values declared in a function definition that act as placeholders for the actual data (arguments) passed in when the function is called. Parameters allow the same function to operate on different data each time it is invoked.
The blanks you fill in when using a function. Like a form with fields.
Read the full concept explanation →How to Use These Examples
- Read the first worked example with the solution open so the structure is clear.
- Try the practice problems before revealing each solution.
- Use the related concepts and background knowledge badges if you feel stuck.
What to Focus On
Core idea: Parameters make functions flexible—same code, different data.
Common stuck point: Parameter (in definition) vs. argument (in call)—often used interchangeably.
Sense of Study hint: When defining parameters, give each one a clear name that describes what data it expects. When calling the function, make sure you pass arguments in the correct order and of the correct type. If a function has many parameters, consider grouping related ones into an object.
Worked Examples
Example 1
easyAnswer
First step
Full solution
- 2 Step 2: The function outputs 'Hello, ' + 'Alice' = 'Hello, Alice'.
- 3 Step 3: When greet('Bob') is called, name = 'Bob', so it outputs 'Hello, Bob'. Parameters allow the same function to work with different inputs.
Example 2
mediumExample 3
easyExample 4
mediumExample 5
mediumExample 6
hardExample 7
challengePractice Problems
Try these problems on your own first, then open the solution to compare your method.
Example 1
mediumExample 2
hardExample 3
easyExample 4
easyExample 5
easyExample 6
easyExample 7
easyExample 8
easyExample 9
easyExample 10
easyExample 11
mediumExample 12
mediumExample 13
mediumExample 14
mediumExample 15
mediumExample 16
mediumExample 17
mediumExample 18
challengeExample 19
challengeExample 20
challengeExample 21
mediumExample 22
mediumExample 23
easyExample 24
easyExample 25
easyExample 26
easyExample 27
mediumExample 28
mediumExample 29
mediumExample 30
mediumExample 31
mediumExample 32
mediumExample 33
mediumExample 34
mediumExample 35
mediumExample 36
hardExample 37
hardExample 38
hardExample 39
hardExample 40
challengeRelated Concepts
Background Knowledge
These ideas may be useful before you work through the harder examples.