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 double(n): return n * 2 print('done') | AOutput: 8 | |
| 2def greet(): print('Hi') result = greet() print(result + '!') | BError: greet() returns None | |
| 3def double(n): return n * 2 result = double(5) | CError: Code after return unreachable | |
| 4def is_even(n): return n % 2 == 0 | DValid: result stores 10 | |
| 5def double(n): return n * 2 print(double(4)) | EOutput: Hello None | |
| 6def hi(): print('Hello') print(hi()) | FOk: Returns True or False |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
return — Sends a value back to the code that called the function.~~Return valuedef add(a, b):
return a + b
result = add(3, 5)def double(n):
return n * 2
print(double(5))def square(n):
return n ** 2def greet(name):
return 'Hello ' + name
msg = greet('Al')def is_even(n):
return n % 2 == 0