Paper 1 Programming Fundamentals Answers
These answers correspond to Paper 1 Programming Fundamentals Drills.
Answer 1: Data Types
| Variable | Suitable data type | Reason |
|---|---|---|
student_id | string | contains a letter and digits; not used for arithmetic |
age | integer | whole-number count of years |
height_m | real / float | may contain a decimal part |
has_paid | Boolean | stores True or False |
class_code | string | contains a digit and letter; represents a label |
Mark points:
- 1 mark for each suitable type.
- Accept
str,int,float, andboolas Python-specific names.
Common weak answer:
- using integer for
student_idorclass_codejust because the value contains digits.
Answer 2: Identifier Quality
Suitable improved identifiers:
total_marks = 240
number_of_students = 4
average_mark = total_marks / number_of_studentsBenefit:
- Meaningful identifiers make the purpose of each value clear, so the code is easier to read, debug, and maintain.
Mark points:
- 1 mark for a meaningful name for
a; - 1 mark for a meaningful name for
b; - 1 mark for a meaningful name for
c; - 1 mark for a valid benefit such as readability, maintainability, or reduced misunderstanding.
Common weak answer:
- changing
a,b, andctox,y, andz; the names are different but still not meaningful.
Answer 3: 2D List Indexing
marks[1][2]is19.marks[2][0]is8.marks[0][1]is15.
Reasoning:
- The first index selects the row.
- The second index selects the item within that row.
- Python list indexes start at
0.
Mark points:
- 1 mark for each correct value.
Common weak answer:
- treating the indexes as starting from
1, which would select the wrong row or column.
Answer 4: Selection Trace
mark | result |
|---|---|
82 | "distinction" |
50 | "pass" |
49 | "resit" |
Mark points:
82 >= 75, so the first branch is taken.50is not at least75, but it is at least50, so theelifbranch is taken.49is below50, so theelsebranch is taken.
Common weak answer:
- saying
50is"resit"because it is not greater than50; the condition is>= 50, so50is included.
Answer 5: Loop Trace
| Iteration | number | branch taken | total after iteration |
|---|---|---|---|
| 1 | 3 | odd branch | 3 |
| 2 | 5 | odd branch | 8 |
| 3 | 2 | even branch | 12 |
| 4 | 4 | even branch | 20 |
Reasoning:
- Odd numbers add their own value.
- Even numbers add twice their value.
Mark points:
- 1 mark for the correct
numbersequence; - 1 mark for identifying odd/even branch choices;
- 1 mark for the first two running totals,
3and8; - 1 mark for the third running total,
12; - 1 mark for the final running total,
20.
Follow-through can be allowed after one arithmetic error if the row-by-row tracing method is otherwise clear, but the final total mark requires the correct final value.
Common weak answer:
- writing only the final total without showing the intermediate states.
Answer 6: Function Purpose
Two valid reasons:
- A function avoids repeating the same expression in several places.
- If the tax rate changes from
1.09, the calculation only needs to be updated in one function. - The function name
calculate_totalmakes the purpose of the calculation clearer. - The function can be tested separately with known inputs and outputs.
Mark points:
- 1 mark for each distinct valid reason, up to 2 marks.
Common weak answer:
- saying only that functions are “better” without explaining a specific benefit.
Answer 7: Recursion Base Case
- The base case is:
if n == 0:
return 1- The base case is needed because it stops the recursive calls. Without it, the function would keep calling itself and eventually cause a recursion error.
Mark points:
- 1 mark for identifying
n == 0andreturn 1; - 1 mark for explaining that the base case stops recursion.
Common weak answer:
- saying the base case is
return n * factorial(n - 1). That is the recursive case, not the stopping case.
Answer 8: String Operation
word[0]is"C".word[3:7]is"PUTI".word[-1]is"G".
Reasoning:
index: 0 1 2 3 4 5 6 7 8
letter: C O M P U T I N GThe slice word[3:7] includes indexes 3, 4, 5, and 6, but excludes index 7.
Mark points:
- 1 mark for each correct value.
Common weak answer:
- including the stop index and giving
"PUTIN"forword[3:7].
Answer 9: Coding Standards
The statement print("large") should be indented inside the if block:
score = 72
if score >= 50:
print("large")In Python, indentation defines which statements belong to a block. Without the indentation, the code causes an IndentationError because Python expects an indented statement after the if line.
A purposeful comment or meaningful identifier helps maintenance because it explains the role or intention of the code. For example, a name such as score is clearer than x, and a useful comment can explain a non-obvious rule rather than repeating the code.
Mark points:
- 1 mark for identifying that
print("large")is not indented inside theifblock; - 1 mark for stating the effect, such as
IndentationErroror the fact that Python cannot form the intended block; - 1 mark for explaining a precise maintainability benefit of a meaningful identifier or purposeful comment.
Common weak answer:
- saying only “comments make code good” without explaining how they help a reader understand or maintain the program.
Answer 10: Decision Table
| has_ticket | is_late | Action |
|---|---|---|
| True | False | allow entry |
| True | True | deny entry |
| False | False | deny entry |
Reasoning:
- The rule requires
has_ticketto beTrue. - The rule also requires
is_lateto beFalse. - If either requirement is not met, entry is denied.
Mark points:
- 1 mark for allowing entry when
has_ticketisTrueandis_lateisFalse; - 1 mark for denying entry when
has_ticketisTrueandis_lateisTrue; - 1 mark for denying entry when
has_ticketisFalse.
Common weak answer:
- allowing entry whenever
has_ticketisTruewithout checking whether the person is late.