Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1def area(width, height): | Aarea(height=3, width=5) | |
| 2area(5, 3) | BThe positional arguments are in the wrong order, so name receives 16 and age receives 'Zoe'. | |
| 3A keyword argument names the parameter it is giving a value to, so the order does not matter | Cwidth and height are parameters: names in the definition that will receive values | |
| 4The number of arguments in a call must match the number of parameters in the definition (unless defaults are set) | DThe function has two parameters but the call gives only one argument, so Python raises a TypeError for the missing argument b. | |
| 5def total(a, b): return a + b total(4) | Edef greet(name, town): greet('Ava', 'Perth') | |
| 6def info(name, age): print(name, age) info(16, 'Zoe') | F5 and 3 are arguments: the actual values passed in the call, matched by position |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
parameter — The name in a function definition that receives a value, like name in def greet(name). The value passed in the call, like greet('Ava'), is the argument.def greet(name):
print('Hello, ' + name)def area(w, h):
return w * h
print(area(w=4, h=5))def sub(a, b):
return a - b
print(sub(10, 4)) # 6def intro(name, age):
print(name, age)
intro('Ava', 16)def greet(name):
print('Hi ' + name)
greet(name='Ava')