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 | |
|---|---|---|
| 1total_price = price * quantity | AUnclear single-letter names do not tell the reader what the values mean. Use names like subtotal and discount. | |
| 2def show_total(price, qty): return price * qty | Bdef greet(name): print("Hello " + name) greet("Ava") greet("Liam") | |
| 3Removing repeated code by putting it in a function that you call each time | CThe same line is repeated many times. Use a function or a loop so the code is written once. | |
| 4Consistent indentation and spacing show which lines belong together | Dif score >= 50: print("Pass") else: print("Try again") | |
| 5x = a * b z = x - 5 | EA meaningful variable name that tells the reader what the value stores | |
| 6print("Hi Ava") print("Hi Liam") print("Hi Mia") print("Hi Noah") | FA short function with consistent indentation that does one clear job |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
readable code — Code that people can quickly understand, using clear names, consistent indentation and spacing, short functions with no repeated code, and helpful comments.total = price * quantity
print("Total:", total)def border():
print("-" * 20)# Add 10 percent GST to the price
gst = price * 0.1for mark in marks:
print(mark)def addgst(price):
return price * 1.1
print(addgst(50))