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 | |
|---|---|---|
| 1GST_RATE = 0.1 | ADefines a constant named GST_RATE with the value 0.1, set once and not changed while the program runs | |
| 2total = price * GST_RATE | BThe constant is written in lower case. By convention constants use UPPER_CASE, such as GST_RATE, so readers know it must not change. | |
| 3A magic number is an unexplained value typed directly into code, which a named constant avoids | CThe constant is reassigned partway through the program. A constant must be set once and never changed while the program runs. | |
| 4A variable can change as the program runs, but a constant should stay the same | DUses the constant's name instead of a magic number, so the 0.1 is not hard-coded in the calculation | |
| 5gst_rate = 0.1 | Escore = score + 1 | |
| 6GST_RATE = 0.1 GST_RATE = 0.15 | Ftax = price * 0.1 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
GST_RATE = 0.1 — A constant: a named value set once and never changed while the program runs. Written in UPPER_CASE by convention, it replaces magic numbers and is easy to update in one place.GST_RATE = 0.1GST = 0.1total = price * (1 + GST_RATE)if score >= PASS_MARK:seconds = minutes * SECONDS_PER_MINUTE