Functions – Parameters, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
Functions – Parameters in one minute
What students need to know
'Alice' is passed as the argument for the parameter 'name'. Multiple parameters are separated by commas in the def line.
Parameters are the names in the def line — they receive the argument values. Arguments are the values you pass when calling the function.
Mistakes students make
- Missing colon after the parameter list.
- Parameters don't use quotes: name is a variable, not a string.
- Multiple parameters must be separated by commas.
- Missing argument: greet expects a name but got nothing.
PREVIOUS · MODULE 24Functions – Defining
YOU ARE HERE · MODULE 25Functions – Parameters
NEXT · MODULE 26Functions – Return Values
What students will learn in this module
Every question in Module 25
Quick questions
- What is a parameter?AThe function nameBA variable in the function definition
- What is an argument?AThe actual value passed to a functionBThe function name
- def greet(name):\n print('Hi ' + name)\ngreet('Bob')\nWhat prints?AHi BobBHi name
- def add(a, b):\n print(a + b)\nadd(3, 5)\nWhat prints?A35B8
- Can a function have multiple parameters?AYes separated by commasBNo only one
Key terms
Students type the meaning of:
ParameterArgumentdef greet(name):greet('Alice')
Match the pairs
def add(a, b):
return a + b
add(3)Match it to what it doesdef greet(name):
print('Hi ' + name)
greet('Al', 'Bob')Match it to what it doesdef greet(name):
print('Hi ' + name)
greet('Alice')Match it to what it doesdef add(a, b):
return a + bMatch it to what it doesdef square(n):
return n * n
print(square(4))Match it to what it doesdef add(a, b):
return a + b
print(add(3, 5))Match it to what it doesFill in the blanks
def greet(____): print('Hi ' + name) greet('Alice')def add(a, _): print(a + b) add(3, 5)def greet(name): print('Hi ' + name) greet(_____)def double(______): print(number * 2) double(5)def show(x, y): print(x + y) show(_, 10)
Spot the error
Question 1
Adef greet(name)B msg = 'Hi ' + nameC print(msg)D print('Goodbye!')Egreet('Alice')
Question 2
Adef greet('name'):B msg = 'Hi ' + nameC print(msg)D print('Goodbye!')Egreet('Alice')
Question 3
Adef add(a b):B result = a + bC print('Sum:', result)D return resultEadd(3, 5)
Question 4
Adef greet(name):B print('Hi ' + name)CDgreet()
Question 5
Adef greet(name):B print('Hi ' + name)CDgreet('Alice', 'Bob')
