OCR GCSE Python Project Vault
Programming Constructs

In the OCR GCSE specification, you need to use the 3 main programming constructs to control the flow of your code.

1. Sequence

Code is executed line-by-line, from top to bottom. Every instruction runs in the exact order it is written.

# Example: Executing one step after another
print("Welcome!")
name = input("Enter your name: ")
print("Hello", name)

2. Selection

Making decisions in code. The program takes different paths based on whether a condition is True or False.

# Example: Checking a condition
age = int(input("Enter your age: "))

if age >= 18:
    print("You are an adult.")
elif age == 17:
    print("Almost an adult!")
else:
    print("You are a child.")

3. Iteration

Repeating blocks of code (looping). There are two types: Count-controlled (FOR loops) and Condition-controlled (WHILE loops).

# Count-controlled (FOR loop)
# Repeats a set number of times
for i in range(3):
    print("Loop number", i)

# Condition-controlled (WHILE loop)
# Repeats until a condition is met
keep_going = True
while keep_going == True:
    ans = input("Stop? (y/n): ")
    if ans == "y":
        keep_going = False
Variables & Input ▶
Bronze — Personal Greeting
Create a program that asks for a user's name and age. Requirements:
  • Store inputs in variables
  • Display a personalised greeting
  • Use sensible variable names
  • Add a comment to explain your code
Silver — Area Calculator
Create a rectangle area calculator. Requirements:
  • Ask for width and height
  • Calculate area correctly
  • Use appropriate arithmetic operators
  • Output the area with a suitable message
Gold — Shopping Receipt
Create a shopping receipt generator. Requirements:
  • Input prices until the user enters -1
  • Calculate total cost
  • Display the final cost to 2 decimal places
Platinum — Receipt VAT Calculator
Extend the receipt system. Requirements:
  • Use a function to calculate a price after 20% VAT is applied
  • The function should return a float
Selection ▶
Bronze — Pass or Fail
Create a pass/fail checker. Requirements:
  • Input a percentage mark (e.g. 60)
  • Use if/else
  • Display "Pass" if the grade is above 60%
  • Otherwise display "Fail"
  • Add a comment to explain the boolean logic
Silver — Grading System
Add greater control. Requirements:
  • Add a "Merit" output for above 80%
  • Add a "Distinction" output for above 90%
  • Use elif correctly
  • Handle invalid inputs (e.g. 110%)
Gold — Login System
Design a secure login system. Requirements:
  • Take an input password
  • Check this against a constant string called PASSWORD
  • Output "Access Granted" if the passwords match
  • Otherwise output "Access Denied"
  • The user should be allowed 3 attempts to enter the correct password
Platinum — login system
Extend the login system. Requirements:
  • Take a username and password as an input
  • Store existing username and passwords as records in a 2D array
  • Check if the inputs are a correct username and password pair
  • Output messages the same as the silver challenge
Iteration ▶
Bronze — Count to 10
Print numbers from 1 – 10. Requirements:
  • Use a suitable loop
  • Add a comment to explain your code
  • Use sensible variable names
Silver — Even Number Generator
Generate even numbers. Requirements:
  • Use modulus operator
  • Output ONLY the even numbers from 1 – 50
Gold — FizzBuzz
Create a scalable FizzBuzz system. Requirements:
  • Modify your previous code so that:
  • Every number from 1 - 50 is output
  • If the number is divisible by 3 "Fizz" is output
  • If the number is divisible by 5 "Buzz" is output
  • If the number is divisible by both 3 and 5 "FizzBuzz" is output
Platinum — FizzBuzz function
Modify your FizzBuzz code. Requirements:
  • Use a function called FizzBuzz to generate the output message
  • The function should take 1 variable for the number
  • The function should return a string containing either "Fizz", "Buzz" or "FizzBuzz"
  • Integrate this function into your origional code for the numbers 1 - 50
String Handling ▶
Bronze — Password Checker
Check that the users new password follows the rules. Requirements:
  • Check minimum length (at least 8 characters)
  • If the password isn't the correct length prompt the user for a new password until they reach the minimum required
  • Provide a suitable message when prompting the user to try again
  • Provide a suitable message when the user enters a satisfactory password
Silver — Password Checker
Extend your existing code. Requirements:
  • It is now required that the users password must contain a special character (e.g. ?!)
  • Provide a suitable message when prompting the user to try again
  • Your message should explain if the password was rejected for length, the lack of a special character or both
Gold — Password Checker
Extend your existing code. Requirements:
  • Create a 2D array of passwords
  • When a user successfully creates a password add this to the array
  • If a password appears more than 5 times it is now commonly used and they may not choose this password
  • Provide a suitable message when prompting the user to try again
Platinum — Caesar Cipher
Create a Caesar cipher. Requirements:
  • Encrypt text
  • Decrypt text
  • Handle spaces
  • Use loops and strings together
Lists ▶
Bronze — Favourite Foods
Store favourite foods in a list. Requirements:
  • Add at least 5 items
  • Output each item in the list in order using a loop
Silver — Number Statistics
Analyse a list of numbers. Requirements:
  • use the list numbers = [5,3,10,6,13,7,4,1]
  • Find maximum value
  • Find minimum value
  • Calculate average
  • Use iteration correctly
Gold — To-Do List App
Create a to-do list manager. Requirements:
  • Add tasks
  • Remove tasks
  • Display all tasks
  • Use a menu to select between add task, remove task or view tasks
Platinum — To-Do List App
Upgrade the To-Do list. Requirements:
  • Create a proceedure for each feature (adding tasks, removing tasks, viewing tasks)

Exam Questions