Paper 1 Programming Fundamentals Answers

These answers correspond to Paper 1 Programming Fundamentals Drills.

Answer 1: Data Types

VariableSuitable data typeReason
student_idstringcontains a letter and digits; not used for arithmetic
ageintegerwhole-number count of years
height_mreal / floatmay contain a decimal part
has_paidBooleanstores True or False
class_codestringcontains a digit and letter; represents a label

Mark points:

  • 1 mark for each suitable type.
  • Accept str, int, float, and bool as Python-specific names.

Common weak answer:

  • using integer for student_id or class_code just 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_students

Benefit:

  • 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, and c to x, y, and z; the names are different but still not meaningful.

Answer 3: 2D List Indexing

  1. marks[1][2] is 19.
  2. marks[2][0] is 8.
  3. marks[0][1] is 15.

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

markresult
82"distinction"
50"pass"
49"resit"

Mark points:

  • 82 >= 75, so the first branch is taken.
  • 50 is not at least 75, but it is at least 50, so the elif branch is taken.
  • 49 is below 50, so the else branch is taken.

Common weak answer:

  • saying 50 is "resit" because it is not greater than 50; the condition is >= 50, so 50 is included.

Answer 5: Loop Trace

Iterationnumberbranch takentotal after iteration
13odd branch3
25odd branch8
32even branch12
44even branch20

Reasoning:

  • Odd numbers add their own value.
  • Even numbers add twice their value.

Mark points:

  • 1 mark for the correct number sequence;
  • 1 mark for identifying odd/even branch choices;
  • 1 mark for the first two running totals, 3 and 8;
  • 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_total makes 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

  1. The base case is:
if n == 0:
    return 1
  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 == 0 and return 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

  1. word[0] is "C".
  2. word[3:7] is "PUTI".
  3. word[-1] is "G".

Reasoning:

index:  0 1 2 3 4 5 6 7 8
letter: C O M P U T I N G

The 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" for word[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 the if block;
  • 1 mark for stating the effect, such as IndentationError or 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_ticketis_lateAction
TrueFalseallow entry
TrueTruedeny entry
FalseFalsedeny entry

Reasoning:

  • The rule requires has_ticket to be True.
  • The rule also requires is_late to be False.
  • If either requirement is not met, entry is denied.

Mark points:

  • 1 mark for allowing entry when has_ticket is True and is_late is False;
  • 1 mark for denying entry when has_ticket is True and is_late is True;
  • 1 mark for denying entry when has_ticket is False.

Common weak answer:

  • allowing entry whenever has_ticket is True without checking whether the person is late.