Book a lesson
HomeResourcesPython Starter Guide
GCSE Computer Science ยท Python

Python Starter Guide

A comprehensive reference for every Python topic in the OCR GCSE Computer Science specification. Variables, conditions, loops, functions, lists, file handling โ€” with syntax tables, worked code examples, and practice tasks.

Book a sessionAll resources

What this guide covers

Variables and data types โ€” str, int, float, bool with conversion
Selection (if/elif/else) and Boolean operators
For loops, while loops, and input validation patterns
Functions with parameters and return values
Lists, file handling, and string manipulation

Python at a glance

The most common patterns โ€” colour-coded by type.

PYTHON QUICK REFERENCEname = "Dee" # string variableage = 16 # integer variableif age > 13: # selection print("Hello, " + name)for i in range(5): # iteration print(i)# 0,1,2,3,4def greet(name): # function
key termprint()Displays output to the screen
key terminput()Gets text from the user โ€” always returns a string
key termint()Converts a string to a whole number
key termdefKeyword to define a function
key termreturnSends a value back from a function
PYTHON โ€” KEY PATTERNSscore = 0 # integer variablename = "Dee" # string variableif score >= 50: # selection print("Pass")for i in range(5): # iteration print(i) # 0,1,2,3,4def square(n): # function
key termprint()Displays output on screen
key terminput()Gets text from user โ€” always a string
key termint()Converts string to whole number
key termdefDefine a new function
key termreturnSend a value back from a function

What is in this guide?

The Python Starter Guide is a comprehensive reference for every Python topic in the OCR GCSE Computer Science specification. Unlike a tutorial that walks you through one concept at a time, this guide is designed to be used alongside your lessons โ€” look things up, check syntax, and work through the practice tasks for each topic.

How to use this guide

If you are learning a topic for the first time, read the explanation and work through the examples yourself. Type the code โ€” do not copy and paste. If you are revising, use the quick reference tables and practice questions.

Every section ends with a practice task. Do it before moving on.

OCR GCSE Python topics

The OCR specification requires you to know: variables and data types, input and output, selection (if/elif/else), iteration (for and while loops), functions, lists, string manipulation, file handling, and common algorithms (searching, sorting). All are covered here.

Variables and data types

Variables store values. Python automatically detects the data type.

TypeWhat it storesExample
str (string)Textname = "Dee"
int (integer)Whole numbersscore = 85
floatDecimal numbersprice = 9.99
bool (boolean)True or Falsepassing = True

Type conversion

# Convert to integer
age = int(input("Age: "))

# Convert to float  
price = float(input("Price: "))

# Convert to string
print("Score: " + str(score))

String operations

name = "Alice"
print(len(name))       # 5
print(name.upper())    # ALICE
print(name[0])         # A
print(name[1:4])       # lic

Selection and iteration

If statements

score = int(input("Score: "))
if score >= 70:
    print("Grade A")
elif score >= 60:
    print("Grade B")
else:
    print("Below B")

# Boolean operators
if age >= 18 and has_id:
    print("Entry allowed")

Loops

# For loop
for i in range(1, 6):
    print(i)   # 1 to 5

# While loop with input validation
password = ""
while password != "secret":
    password = input("Password: ")

# Loop with list
names = ["Ana","Bob","Cal"]
for name in names:
    print(name)

Functions and lists

Functions

def calculate_average(numbers):
    total = 0
    for n in numbers:
        total += n
    return total / len(numbers)

result = calculate_average([8,7,9,6])
print(result)   # 7.5

Lists

# Create and access
scores = [8, 7, 9, 6, 10]
print(scores[0])    # 8 (first item)
print(scores[-1])   # 10 (last item)

# Modify
scores.append(9)    # add to end
scores.remove(7)    # remove value
scores.sort()       # sort in place
print(len(scores))  # count items

File handling

File handling appears in GCSE exams. You need to know how to open, read, write, and close files.

# Reading from a file
with open("data.txt", "r") as f:
    content = f.read()
    print(content)

# Reading line by line
with open("data.txt", "r") as f:
    for line in f:
        print(line.strip())

# Writing to a file
with open("output.txt", "w") as f:
    f.write("Hello, world!\n")
    f.write("Second line\n")

# Appending to a file
with open("log.txt", "a") as f:
    f.write("New entry\n")

Using with open() automatically closes the file when the block ends โ€” this is the recommended approach.

Want to go through these topics with a tutor?

Miss ICT GCSE sessions cover every Python topic on the OCR specification. Dee works through examples, checks understanding, and focuses on the specific areas that cause problems.

Book a GCSE sessionPython for beginners

Frequently asked questions

Do I need to know everything in this guide for my GCSE?

You need variables, data types, input/output, selection, iteration, functions, lists, string operations, and file handling. These are all covered here and all appear in OCR GCSE exams.

Are there other Python topics not in this guide?

Yes โ€” dictionaries, exception handling, and object-oriented programming are relevant at A Level but not required at GCSE. This guide covers the GCSE specification.

How should I practise?

Write every example yourself. Then change something โ€” break it deliberately, then fix it. Create small programs that use each feature. Practice questions are at the end of each section.

Related

Python

Python for Beginners

Start from scratch โ€” variables, conditions, loops explained

Debugging

Python Emergency Kit

Fix the most common Python errors immediately

GCSE

Algorithms Explained

Searching and sorting in pseudocode and Python

Tutoring

1-to-1 GCSE Tutoring

Expert support from a GCSE examiner

Book a session โ†’
โœ” GCSE examiner ยท โœ” DBS checked