Skip to content
Book 8: Algorithms, Programming and Databases

Book 8 · Chapter 0

How Paper 2 works

Exam craftExam craftB8·0

This chapter is in the ebook.

Read it in full on cswithzak.com. Every question has its mark scheme and every program is ready to run. The free practice for each section is below, with the short code the book prints beside it.

Open in the ebook

About this chapter

This chapter is about how the paper works rather than one syllabus section. Its companion material arrives with the chapter.

The paper at a glance

Short code B8·0·10

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Reading the question: command words

Short code B8·0·11

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

How Python answers are marked

Short code B8·0·12

temp = int(input("Enter the temperature: "))
while temp < -10 or temp > 50:
    temp = int(input("Out of range. Enter again: "))
print("Accepted:", temp)
The Mark Ladder's answer, run with 72 (refused) and then 23. The two prompts appear in the output because input() prints its prompt before it waits.

Output

Enter the temperature: Out of range. Enter again: Accepted: 23
Run and checked before printing
quantity = int(input("How many tickets (1 to 20)? "))
while quantity < 1 or quantity > 20:
    quantity = int(input("1 to 20 only. Enter again: "))
print("Booked:", quantity)
The faded twin's answer, run with 0 (refused), 25 (refused) and then 4.

Output

How many tickets (1 to 20)? 1 to 20 only. Enter again: 1 to 20 only. Enter again: Booked: 4
Run and checked before printing
total = 17
print("Total:", total)
print("Total: " + str(total))
Two ways to put a number in a message: a comma in print(), or str() before +. Both print the same words; the comma also adds the space.

Output

Total: 17
Total: 17
Run and checked before printing

Trace tables, the examiner's way

Short code B8·0·13

hot = 0
cold = 0
total = 0
print("start", hot, cold, total)
for day in range(5):
    temp = int(input())
    if temp >= 30:
        hot = hot + 1
    elif temp < 10:
        cold = cold + 1
    total = total + temp
    print(day, temp, hot, cold, total)
print("output:", hot, cold, total / 5)
The trace-it program with one print added inside the loop, so every row of the trace table comes from a real run. Inputs: 31, 12, 8, 30, -2.

Output

start 0 0 0
0 31 1 0 31
1 12 1 0 43
2 8 1 1 51
3 30 2 1 81
4 -2 2 2 79
output: 2 2 15.8
Run and checked before printing
count = 0
biggest = 0
n = int(input())
print("start", count, biggest, n)
while n != 0:
    count = count + 1
    if n > biggest:
        biggest = n
    n = int(input())
    print(count, biggest, n)
print("output:", count, biggest)
The faded twin's program with a print added after each input. Inputs: 7, 3, 9, 0.

Output

start 0 0 7
1 7 3
2 7 9
3 9 0
output: 3 9
Run and checked before printing

Flowcharts in Paper 2

Short code B8·0·14

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Short programming questions

Short code B8·0·15

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

SQL answers

Short code B8·0·16

SELECT Name, Form
FROM PUPIL
INNER JOIN CLUB ON PUPIL.ClubID = CLUB.ClubID
WHERE ClubName = 'Chess'
ORDER BY Name;
The Mark Ladder's statement, run on the PUPIL and CLUB tables.

Output · 3 rows

NameForm
Bilal10A
Dina11A
Eesa10B
Run and checked before printing
SELECT COUNT(PupilID)
FROM PUPIL
INNER JOIN CLUB ON PUPIL.ClubID = CLUB.ClubID
WHERE MeetDay = 'Tuesday';
The faded twin's statement, run on the same tables.

Output

COUNT(PupilID)
3
Run and checked before printing
SELECT Name, Form
FROM PUPIL
INNER JOIN CLUB ON PUPIL.ClubID = CLUB.ClubID
WHERE ClubName = Chess;
What the engine says when the quotation marks are left off the text value.

Output

ERROR: Chess is not a column — text values must be in quotes: ClubName = 'Chess'.
Run and checked before printing

The 15-mark scenario: how it is built

Short code B8·0·17

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

A worked scenario, point by point

Short code B8·0·18

# Recycling drive: bottles collected by each class on each day
classes = ["7A", "7B", "8A", "8B"]
DAYS = 3

# (a) one row per class, one column per day, every element 0
bottles = []
for c in range(len(classes)):
    row = []
    for d in range(DAYS):
        row.append(0)
    bottles.append(row)

# (b) input each count, re-input until it is 0 to 500
for c in range(len(classes)):
    for d in range(DAYS):
        print("Bottles for", classes[c], "on day", d + 1)
        count = int(input())
        while count < 0 or count > 500:
            print("Must be 0 to 500. Enter it again")
            count = int(input())
        bottles[c][d] = count

# (c) each class's total and daily average
totals = []
for c in range(len(classes)):
    total = sum(bottles[c])
    totals.append(total)
    average = round(total / DAYS, 1)
    print(classes[c], "collected", total, "- average", average)

# (d) the highest total, and every class that reached it
highest = max(totals)
print("Highest total:", highest)
for c in range(len(classes)):
    if totals[c] == highest:
        print("Winner:", classes[c])
The whole recycling-drive program: parts (a) to (d) one after the other. Notice the comment that names each part, and that every name the scenario gave (classes, bottles, totals, DAYS) is used exactly as given.
Run and checked before printing

Output

Bottles for 7A on day 1
Bottles for 7A on day 2
Bottles for 7A on day 3
Bottles for 7B on day 1
Bottles for 7B on day 2
Must be 0 to 500. Enter it again
Bottles for 7B on day 3
Bottles for 8A on day 1
Bottles for 8A on day 2
Bottles for 8A on day 3
Bottles for 8B on day 1
Bottles for 8B on day 2
Bottles for 8B on day 3
7A collected 127 - average 42.3
7B collected 139 - average 46.3
8A collected 139 - average 46.3
8B collected 125 - average 41.7
Highest total: 139
Winner: 7B
Winner: 8A
Run and checked before printing
names = ["Iman", "Jude", "Kofi", "Lena", "Musa"]
times = [48, 39, 52, 39, 41]
fastest = min(times)
print("Fastest time:", fastest)
for i in range(len(names)):
    if times[i] == fastest:
        print("Fastest:", names[i])
The faded twin's context: every name that shares the fastest time is printed, not just the first.

Output

Fastest time: 39
Fastest: Jude
Fastest: Lena
Run and checked before printing

Timing and checking

Short code B8·0·19

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

How marks are lost

Short code B8·0·20

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Diagnostic set and the scenario

Short code B8·0·21

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Workbook: How Paper 2 works

Short code W8·0 · Algorithms, Programming and Databases Workbook

The write-in workbook for this chapter has drills, exam-style practice, trace tables, fix-the-mistake and mark-it-yourself pages. Its full mark schemes and an interactive version arrive here with the chapter.

Ask Z about How Paper 2 works
Buy ZAK's books — WhatsApp the books desk: Buy the booksPrint or ebook