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 is_even(n): return n % 2 == 0 | AA simple one-job function: it only checks whether a number is even and returns True or False. | |
| 2total = sum(marks) | BUses the built-in sum() to add up a list in one clear line instead of writing a longer loop. | |
| 3Give each function one job so it is easier to test and reuse | Cdef calc_average(marks): return sum(marks) / len(marks) | |
| 4Avoid unnecessary complexity by returning the condition result directly | DThis is unnecessarily complex. The comparison already gives True or False, so use result = score >= 50. | |
| 5def do_everything(): name = input('Name: ') mark = int(input('Mark: ')) print(name, mark * 2) save_to_file(name, mark) | Ereturn age >= 18 | |
| 6if score >= 50: result = True else: result = False | FOne function does many jobs: input, calculation, printing and saving. It should be split into small functions with one job each. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
KISS — Keep It Simple: solve the problem with the clearest, shortest logic, avoiding extra complexity and giving each function one job, so code is easier to read, test and maintain.def even(n):
return n % 2 == 0def area(w, h): return w * hdef double(n): return n * 2adult = age >= 18for mark in marks:
print(mark)