Colour-coded by concept type โ variables, selection, iteration, functions.
Python is the programming language used in OCR GCSE and A Level Computer Science. It is also one of the most widely used languages in the world โ in data science, artificial intelligence, and automation. Its syntax reads almost like English, making it one of the most approachable first languages.
You do not need to install anything. Use repl.it or trinket.io to run Python directly in the browser. Both are free, no setup required.
If you prefer a local install, download Python 3 from python.org. Always use Python 3 โ the syntax is different to Python 2 in ways that matter in exams.
Python reads your code line by line from top to bottom. If it hits an error it stops and tells you which line caused the problem and what went wrong. Reading error messages carefully is one of the most important debugging skills.
This make-and-fix cycle is the fastest way to learn.
A variable stores a value your program can use and change. In Python you create one with a name and the = sign. Python automatically detects the data type.
name = "Dee" age = 32 score = 8.5 passing = True print(name) # Dee print(age) # 32
The input() function waits for the user to type something. It always returns a string โ convert with int() or float() if you need a number.
name = input("Your name: ")
age = int(input("Your age: "))
print("Hello " + name)If statements let your program choose different paths based on conditions. Python uses indentation (4 spaces or 1 tab) to define what belongs inside the block.
score = int(input("Enter your score: "))
if score >= 70:
print("Grade A")
elif score >= 60:
print("Grade B")
elif score >= 50:
print("Grade C")
else:
print("Below pass")Using = instead of == inside a condition is one of the most common GCSE exam errors.
Forgetting the colon at the end of the if line is another. Python will give an IndentationError or SyntaxError when this happens.
Loops repeat a block of code. For loops repeat a fixed number of times. While loops repeat as long as a condition is true.
# Count from 0 to 4
for i in range(5):
print(i)
# Count from 1 to 5
for i in range(1, 6):
print(i)
# Loop through a list
fruits = ["apple","banana","cherry"]
for fruit in fruits:
print(fruit)count = 0
while count < 5:
print(count)
count = count + 1
# Input validation loop
password = ""
while password != "secret":
password = input("Enter password: ")
print("Access granted")A function is a named block of code that you define once and can call many times. Functions make programs shorter, easier to read, and much easier to debug.
def calculate_grade(score):
if score >= 70:
return "A"
elif score >= 60:
return "B"
elif score >= 50:
return "C"
else:
return "U"
result = calculate_grade(75)
print(result) # A
print(calculate_grade(55)) # Cdef starts the function definition. return sends a value back to whatever called the function. A function without return still runs but gives back None.
Parameters are the variable names in the function definition. Arguments are the actual values you pass in when calling the function.
Variables created inside a function only exist inside it. Variables defined outside can be read inside but usually not changed โ unless declared global.
Python can feel overwhelming when taught too quickly. These three habits make the difference between confusion and confidence.
Python errors tell you exactly which line failed and what went wrong. Ignoring them and just changing things randomly is the slowest way to debug.
Copy-pasting code does not build memory. Type every example. Make deliberate mistakes. Fix them. That is how understanding forms.
Master variables before moving to conditions. Master conditions before loops. Trying to learn everything at once leads to everything feeling confusing.
Miss ICT GCSE sessions include dedicated Python support โ variables, loops, functions, lists, and file handling, all aligned to OCR specification with examiner-led focus on what gets marks.
OCR uses Python 3. Python 2 is obsolete. The key differences that matter in exams are the print function (Python 3 requires brackets) and how integer division behaves.
You need to know core Python for programming questions: variables, if statements, loops, functions, lists, string operations, and file handling. OCR provides pseudocode reference โ not a Python cheat sheet.
print() displays a value on the screen. return sends a value back from a function to the code that called it. They do completely different things โ confusing them is one of the most common A Level mistakes.
Python uses indentation to define code blocks. Every line inside an if, for, while, or def must be indented by the same amount โ 4 spaces is standard. IndentationError means a line is at the wrong level.
Every OCR Python topic โ variables, loops, functions, lists, file handling
Fix the 5 most common Python errors immediately
The ideas that sit underneath Python and all programming
Pseudocode, searching, sorting โ linked to Python thinking