Edexcel GCSE Computer Science

Paper 2: Application of Computational Thinking

FORECAST PRACTICE EXAM

⏱️ Time: 2 hours πŸ“ Total: 75 marks πŸ’» 6 Questions

⚠️ PRACTICE MODE - EXTRA SUPPORT ENABLED

This practice exam includes PLS hints shown in yellow boxes. In the REAL EXAM, you will NOT see these hints β€” you must find the information yourself in the Programming Language Subset (PLS) document provided. Use this practice to learn WHERE to find information in the PLS!

Question 1: Bicycle Hire Calculator

πŸ“Š 10 marks ⏱️ Suggested time: 15 minutes πŸ“‚ Save as: Q01FINISHED.py

A program calculates the cost of hiring a bicycle. The hire cost is calculated by multiplying the number of hours by the hourly rate. A discount of 15% is applied if the customer is a member.

The program must:

  • Store the hourly rate as a constant (Β£8.50)
  • Accept the number of hours from the user
  • Accept whether the customer is a member (Y or N)
  • Calculate the total cost
  • Apply a 15% discount if the customer is a member
  • Display the final cost to 2 decimal places

Test data:

HoursMemberExpected Output
3NΒ£25.50
4YΒ£28.90
2YΒ£14.45

Open file Q01.py. Amend the code to:

  • create a constant for the hourly rate of 8.50
  • create a variable to store the number of hours as an integer
  • take input from the user for hours and membership status
  • calculate the cost using the formula: cost = hours Γ— rate
  • apply the discount using selection
  • display the result formatted to 2 decimal places

πŸ“– PLS Reference: Data Types (p.5), Operators (p.6), Selection (p.7), Formatting Strings (p.12)

Constants: Use UPPERCASE names β†’ RATE = 8.50 Type conversion: int(input("prompt")) for integers Selection: if condition: statement else: statement Formatting: "{:.2f}".format(value) for 2 decimal places
⚠️ IN THE REAL EXAM: This hint box will NOT appear. You must find this information in the PLS document yourself. Practice locating these sections now!
πŸ“ Q01.py
πŸ’» Output
Output will appear here...

Question 2: Turtle Graphics - House Drawing

πŸ“Š 10 marks ⏱️ Suggested time: 15 minutes πŸ“‚ Save as: Q02FINISHED.py

A program uses turtle graphics to draw a simple house shape. The program has errors and does not work correctly.

The house consists of:

  • A square base (100 Γ— 100 pixels)
  • A triangular roof on top
  • The base should be filled with colour "skyblue"
  • The roof should be filled with colour "red"

Open file Q02.py. Amend the code to:

  • fix the NameError on original line 3: import turtl
  • fix the syntax error on original line 8: myTurtle = turtle.Turtle(
  • fix the AttributeError on original line 12: myTurtle.forwrd(100)
  • add a comment on line 15 to explain what setheading() does
  • fix the logic error on line 20 causing wrong roof angle: myTurtle.left(90)
  • complete line 25 to set the fill colour for the roof to "red"
  • complete line 30 to hide the turtle at the end

πŸ“– PLS Reference: Turtle Graphics Library Module (p.14-16)

Import: import turtle Create turtle: myTurtle = turtle.Turtle() Movement: forward(steps), back(steps), left(degrees), right(degrees) Direction: setheading(degrees) β€” sets absolute direction (0=east, 90=north) Filling: begin_fill(), fillcolor("colour"), end_fill() Visibility: hideturtle(), showturtle()
⚠️ IN THE REAL EXAM: This hint box will NOT appear. The PLS has a full turtle reference on pages 14-16. Learn to navigate it!
πŸ“ Q02.py
πŸ’» Output
Output will appear here... Note: Turtle graphics cannot run in this browser environment. Focus on fixing the syntax and logic errors. The code should run without errors when tested in IDLE or another Python IDE.

Question 3: BMI Calculator

πŸ“Š 10 marks ⏱️ Suggested time: 20 minutes πŸ“‚ Save as: Q03FINISHED.py

A program calculates the Body Mass Index (BMI) for a user. The BMI is used to determine if a person is underweight, normal weight, overweight, or obese.

The formula to calculate BMI is:

BMI = weight Γ· heightΒ²
  • weight is measured in kilograms (kg)
  • height is measured in metres (m)

The BMI categories are:

BMI RangeCategory
Below 18.5Underweight
18.5 to 24.9Normal
25.0 to 29.9Overweight
30.0 and aboveObese

Test data:

WeightHeightBMIOutput
701.7522.86Normal
951.8029.32Overweight
501.7017.30Underweight
-51.70β€”Invalid input

The program must:

  • accept weight and height as decimal inputs from the user
  • validate that both values are greater than 0
  • display "Invalid input" if validation fails
  • calculate BMI using the formula
  • display the BMI rounded to 2 decimal places
  • display the correct category based on the BMI

πŸ“– PLS Reference: Conversion (p.5), Operators (p.6), Selection (p.7), Built-in subprograms (p.9)

Type conversion: float(input("prompt")) for decimal numbers Exponentiation: height ** 2 (NOT height^2) Validation: if weight > 0 and height > 0: Multiple conditions: Use elif for each category Rounding: round(value, 2) β€” rounds to 2 decimal places
⚠️ IN THE REAL EXAM: This hint box will NOT appear. Check the Operators table on p.6 for ** (exponentiation) and the Built-in subprograms on p.9 for round().
πŸ“ Q03.py
πŸ’» Output
Output will appear here...

Question 4: Password Generator (Parsons Problem)

πŸ“Š 15 marks ⏱️ Suggested time: 20 minutes πŸ“‚ Save as: Q04FINISHED.py

A program generates a password by taking a word from the user and encoding it. Each letter is replaced with the next letter in the alphabet (A becomes B, Z becomes A). The program also appends the length of the original word to the end.

The program loops continuously until the user enters an empty string to stop.

Test data:

InputOutput
CATDBU3
ZEBRAAFCSB5
"" (empty)Exits program

The lines of code in the program are mixed up.

Amend the code to make the program work and produce the correct output. You will need to rearrange the lines.

The code uses these concepts:

  • ord() to get the ASCII value of a character
  • chr() to convert an ASCII value back to a character
  • String concatenation to build the password
  • A while loop to continue until empty input
  • A for loop to process each character

Do not change the indentation of any line.

πŸ“– PLS Reference: Built-in subprograms (p.9): chr(), ord(), len(). Repetition (p.7), Iteration (p.7)

ord(char): Returns ASCII value β†’ ord('A') = 65, ord('Z') = 90 chr(int): Returns character β†’ chr(66) = 'B' len(string): Returns length β†’ len("CAT") = 3 While loop: while condition: For loop: for char in word: Key insight: Z (ASCII 90) should wrap to A (ASCII 65)
⚠️ IN THE REAL EXAM: This hint box will NOT appear. The chr() and ord() functions are documented on p.9. Remember: DO NOT change indentation in Parsons problems!
πŸ“ Q04.py
πŸ’» Output
Output will appear here...

Question 5: Sports Club Attendance Analysis

πŸ“Š 15 marks ⏱️ Suggested time: 25 minutes πŸ“‚ Save as: Q05FINISHED.py

A sports club stores member attendance data in a file. Each line of the file contains a member name followed by their attendance count, separated by a comma.

Example file content (Q05_DATA.txt):

Smith,12 Jones,8 Brown,15 Wilson,6 Taylor,10

A program and subprogram are required to:

  • read the attendance data from the file
  • calculate the average attendance across all members
  • identify members with above-average attendance
  • write the names of above-average members to a new file (Q05_OUTPUT.txt)
  • display the total number of members and the average attendance

Expected output for the example data:

Total members: 5 Average attendance: 10.2 Above average members written to file

Expected content of Q05_OUTPUT.txt:

Smith Brown

Amend the program and subprogram to meet these requirements:

  • complete the function calculateAverage() that takes a list of attendance values and returns the average
  • read data from the file and store names and attendance values
  • use the split() function to separate the name and attendance on each line
  • call the calculateAverage() function with the attendance values
  • write names of members with attendance above the average to the output file

πŸ“– PLS Reference: Files (p.8), String subprograms: split(), strip() (p.11), Subprograms (p.8)

Open file for reading: file = open("filename.txt", "r") Open file for writing: file = open("filename.txt", "w") Read lines: for line in file: Remove newline: line = line.strip() Split by comma: parts = line.split(",") β†’ parts[0] = name, parts[1] = attendance Function: def functionName(parameter): return value Close file: file.close()
⚠️ IN THE REAL EXAM: This hint box will NOT appear. File operations are on p.8 and string functions like split() and strip() are on p.11. Know these pages well!
πŸ“ Q05.py
πŸ’» Output
Output will appear here... Note: File operations are simulated in this browser environment. Test your complete solution in IDLE or another Python IDE with actual files.

Question 6: Library Book Search

πŸ“Š 15 marks ⏱️ Suggested time: 25 minutes πŸ“‚ Save as: Q06FINISHED.py

A library system stores book information in a two-dimensional array. Each record contains: ISBN, Title, Author, Year Published, and Available (True/False).

The array is sorted alphabetically by Title.

Write a program to meet these requirements:

Inputs

  • Prompt for and accept a book title from the user
  • Accept uppercase and lowercase input (convert to match array format)
  • No other validation is required

Process

  • Create a linear search to locate the book in the array by title
  • Stop the search when:
    • the book is located
    • the expected location of the book is passed (array is sorted)
    • the end of the array is reached
  • Ensure the search works for any length of array

Outputs

  • When the book is found AND available: display "[Title] by [Author] is available"
  • When the book is found but NOT available: display "[Title] is currently on loan"
  • When the book is not found: display "Book not found in catalogue"

Use comments, white space and layout to make the program easier to read and understand.

πŸ“– PLS Reference: Structured data types (p.5), len() (p.9), String: upper()/lower() (p.11), Repetition (p.7)

2D array access: array[row][column] β†’ books[0][1] = first book's title Array length: len(books) β†’ number of rows (books) Case conversion: searchTitle = userInput.lower() or .upper() Linear search pattern: found = False index = 0 while index < len(array) and not found: if array[index][1] == searchValue: found = True else: index = index + 1 Boolean check: if books[index][4] == True: (or just: if books[index][4]:)
⚠️ IN THE REAL EXAM: This hint box will NOT appear. You must know how to access 2D arrays and implement a linear search. The pattern appears in almost every Q6 β€” practise it until it's automatic!
πŸ“ Q06.py
πŸ’» Output
Output will appear here...