YEAR 11 PYTHON COMPETITION
Full Learning Plan & Coding Activities
Terms 1 & 2 | Introduction to Python + Data Structures
Mapped to Competition Segments A, B & C
OVERVIEW OF THE LEARNING PLAN
This learning plan is organised into nine structured activities spread across two blocks matching the
two terms already taught. Each activity includes: a learning objective, step-by-step teacher
instructions, fully worked Python code examples, student tasks, and a clear link to the relevant
competition segment.
Activity Topic Segment Link Approx.
Time
1 Variables, Data Types & Operators Segment A 40 min
2 Control Flow — if/elif/else & loops Segment A 45 min
3 Functions & Scope Segment A 45 min
4 Error Spotting & Debugging Segment A 30 min
5 Lists & Tuples Segments A & B 50 min
6 Dictionaries Segments A & B 50 min
7 Sets & Combined Structures Segment B 45 min
8 Leaderboard Builder (Full Challenge) Segment B 60 min
9 Presentation & Explanation Drill Segment C 40 min
ACTIVITY 1 — Variables, Data Types & Operators
Segment Link: Segment A (Rapid Quiz) | Time: 40 minutes
Learning Objective: Students can declare variables of the correct type, apply arithmetic/comparison
operators, and predict output from simple expressions.
Teacher Introduction (5 min)
Recap the four core data types students need to know for the quiz: int, float, str, bool. Emphasise
that Python is dynamically typed — the type is inferred from the value assigned.
Worked Example 1 — Data Types & type()
# Declaring variables of different types
age = 16 # int
gpa = 3.85 # float
name = 'Amara' # str
passed = True # bool
# Checking types
print(type(age)) # <class 'int'>
print(type(gpa)) # <class 'float'>
print(type(name)) # <class 'str'>
print(type(passed)) # <class 'bool'>
# Type conversion
score_str = '95'
score_int = int(score_str) # converts '95' -> 95
print(score_int + 5) # Output: 100
Worked Example 2 — Operators
a = 17
b = 5
print(a + b) # 22 — addition
print(a - b) # 12 — subtraction
print(a * b) # 85 — multiplication
print(a / b) # 3.4 — true division (returns float)
print(a // b) # 3 — floor division (integer result)
print(a % b) # 2 — modulus (remainder)
print(a ** b) # 1419857 — exponentiation
# Comparison operators return bool
print(a > b) # True
print(a == b) # False
print(a != b) # True
Student Task (20 min)
TASK 1A Write a program that asks the user for two numbers and prints:
- Their sum, difference, product, and quotient (true division)
- Whether the first number is greater than, less than, or equal to the second
TASK 1B Predict the output of the following WITHOUT running the code first, then verify:
x = 10
y=3
print(x % y)
print(x // y)
print(x ** y)
print(x == 10 and y < 5)
Expected Output — Task 1A
Enter first number: 12
Enter second number: 4
Sum: 16
Difference: 8
Product: 48
Quotient: 3.0
12 is greater than 4
Competition Tip
Quiz questions often test: What does // return? (int) | What does / return? (float)
Common trap: '5' + 5 raises a TypeError — you cannot add str and int directly.
ACTIVITY 2 — Control Flow: if/elif/else & Loops
Segment Link: Segment A (Rapid Quiz) | Time: 45 minutes
Learning Objective: Students can write and trace if/elif/else chains and both for and while loops.
Worked Example 1 — Grade Classifier
score = int(input('Enter score (0-100): '))
if score >= 70:
grade = 'A'
elif score >= 60:
grade = 'B'
elif score >= 50:
grade = 'C'
elif score >= 40:
grade = 'D'
else:
grade = 'F'
print(f'Score: {score} | Grade: {grade}')
Worked Example 2 — for Loop with range()
# Print multiplication table for a given number
number = int(input('Enter a number: '))
for i in range(1, 11): # 1 to 10 inclusive
print(f'{number} x {i} = {number * i}')
# --- Output for number = 3 ---
# 3 x 1 = 3
# 3 x 2 = 6
# ... up to 3 x 10 = 30
Worked Example 3 — while Loop with break
# Number guessing game (competition-style mini challenge)
secret = 42
attempts = 0
while True:
guess = int(input('Guess the number: '))
attempts += 1
if guess < secret:
print('Too low!')
elif guess > secret:
print('Too high!')
else:
print(f'Correct! You got it in {attempts} attempts.')
break
Student Task (25 min)
TASK 2A Write a program that prints all even numbers from 1 to 50 using a for loop.
TASK 2B Write a program that keeps asking the user for a positive number.
It should stop when the user enters 0 and print the total sum entered.
TASK 2C Code Trace — write the output of this code WITHOUT running it:
for i in range(1, 6):
if i % 2 == 0:
print(i, 'even')
else:
print(i, 'odd')
Task 2C Expected Output
1 odd
2 even
3 odd
4 even
5 odd
Competition Tip: range(1, 6) gives 1,2,3,4,5 — the stop value is EXCLUDED.
range(0, 10, 2) gives 0,2,4,6,8 — the third argument is the step.
ACTIVITY 3 — Functions & Scope
Segment Link: Segment A (Rapid Quiz) | Time: 45 minutes
Learning Objective: Students can define functions with parameters and return values, and understand
local vs global scope.
Worked Example 1 — Function with Parameters & Return
def calculate_grade(score):
"""Returns letter grade for a given numeric score."""
if score >= 70:
return 'A'
elif score >= 60:
return 'B'
elif score >= 50:
return 'C'
elif score >= 40:
return 'D'
else:
return 'F'
# Calling the function
result = calculate_grade(85)
print(result) # A
print(calculate_grade(45)) # D
Worked Example 2 — Multiple Parameters & Default Values
def greet_student(name, school='Unknown School'):
"""Greets a student with optional school name."""
return f'Welcome, {name} from {school}!'
print(greet_student('Kofi', 'Accra High')) # Welcome, Kofi from Accra High!
print(greet_student('Ama')) # Welcome, Ama from Unknown School!
Worked Example 3 — Scope
total = 0 # global variable
def add_score(score):
result = score * 2 # local variable — only exists inside this function
return result
total = add_score(15)
print(total) # 30
# print(result) # ERROR — result is not accessible outside the function
Student Task (25 min)
TASK 3A Write a function is_even(n) that returns True if n is even, False otherwise.
Test it with at least 5 different values.
TASK 3B Write a function average(scores) that takes a LIST of scores
and returns the average. Handle an empty list gracefully.
TASK 3C Write a function classify_team(scores) that:
- Takes a list of scores
- Uses your average() function from 3B
- Returns 'Gold' if average >= 70, 'Silver' if >= 50, else 'Bronze'
Model Solution — Task 3B & 3C
def average(scores):
if len(scores) == 0:
return 0
return sum(scores) / len(scores)
def classify_team(scores):
avg = average(scores)
if avg >= 70:
return 'Gold'
elif avg >= 50:
return 'Silver'
else:
return 'Bronze'
team_scores = [85, 62, 74, 55, 90]
print(average(team_scores)) # 73.2
print(classify_team(team_scores)) # Gold
ACTIVITY 4 — Error Spotting & Debugging
Segment Link: Segment A (Rapid Quiz) | Time: 30 minutes
Learning Objective: Students can identify syntax errors, logic errors, and runtime errors in short
Python programs.
The Three Error Types
Error Type When it occurs Example
SyntaxError Code cannot be parsed — if x > 5 # missing colon
Python won't run at all
RuntimeError Code starts but crashes during int('hello') # invalid conversion
execution
LogicError Code runs but gives the wrong Using + instead of * in a formula
answer
Debugging Activity — Find & Fix the Bug
Each snippet below contains exactly ONE error. Identify the error type and correct it.
Bug 1
def multiply(a, b)
return a * b
print(multiply(3, 4))
Error type: SyntaxError | Fix: Add colon after def multiply(a, b)
Bug 2
scores = [80, 65, 90, 72]
total = 0
for score in scores:
total = total + score
average = total / 5 # BUG: wrong divisor
print('Average:', average)
Error type: Logic Error | Fix: divide by len(scores) not 5
Bug 3
name = input('Enter your name: ')
age = input('Enter your age: ')
print('In 10 years you will be', age + 10, 'years old.') # BUG
Error type: RuntimeError (TypeError) | Fix: int(age) + 10
Student Task (15 min)
TASK 4 Find and fix all errors in the program below. There are THREE bugs total.
def calculate_total(prices)
total = 0
for price in prices:
total = total + prices # Bug 2
return total
items = [12.50, 8.99, 3.75, 22.00]
result = calculate_total(items)
print('Total: £' + result) # Bug 3
Model Solution
# Bug 1: missing colon after def calculate_total(prices)
# Bug 2: should be 'price' not 'prices' inside loop
# Bug 3: cannot concatenate str and float — use f-string or str()
def calculate_total(prices):
total = 0
for price in prices:
total = total + price
return total
items = [12.50, 8.99, 3.75, 22.00]
result = calculate_total(items)
print(f'Total: £{result}') # Total: £47.24
ACTIVITY 5 — Lists & Tuples
Segment Link: Segments A & B | Time: 50 minutes
Learning Objective: Students can create, modify, and traverse lists and tuples using built-in methods
and loops.
Worked Example 1 — List Operations
scores = [72, 85, 60, 91, 78]
# Indexing & slicing
print(scores[0]) # 72 — first element
print(scores[-1]) # 78 — last element
print(scores[1:4]) # [85, 60, 91] — index 1 to 3
# Useful list methods
[Link](88) # add to end -> [72,85,60,91,78,88]
[Link](60) # remove value -> [72,85,91,78,88]
[Link]() # sort ascending -> [72,78,85,88,91]
[Link](reverse=True) # descending -> [91,88,85,78,72]
print(len(scores)) # 5
print(max(scores)) # 91
print(min(scores)) # 72
print(sum(scores)) # 414
Worked Example 2 — Linear Search
def linear_search(lst, target):
"""Returns index of target in list, or -1 if not found."""
for i in range(len(lst)):
if lst[i] == target:
return i
return -1
names = ['Ama', 'Kofi', 'Abena', 'Kweku', 'Akua']
print(linear_search(names, 'Abena')) # 2
print(linear_search(names, 'Yaw')) # -1
Worked Example 3 — Bubble Sort
def bubble_sort(lst):
n = len(lst)
for i in range(n - 1): # outer pass
for j in range(n - 1 - i): # inner comparison
if lst[j] > lst[j + 1]:
lst[j], lst[j+1] = lst[j+1], lst[j] # swap
return lst
numbers = [64, 34, 25, 12, 22, 11, 90]
print(bubble_sort(numbers)) # [11, 12, 22, 25, 34, 64, 90]
Tuples — Immutable Sequences
# Tuples use () and cannot be changed after creation
student = ('Akua', 17, 'Year 11') # (name, age, year_group)
print(student[0]) # Akua
print(student[1]) # 17
print(len(student)) # 3
# Unpacking a tuple
name, age, year = student
print(f'{name} is {age} years old in {year}')
# List of tuples — common in competition problems
results = [('Ama', 88), ('Kofi', 72), ('Abena', 95)]
[Link](key=lambda x: x[1], reverse=True) # sort by score desc
print(results) # [('Abena', 95), ('Ama', 88), ('Kofi', 72)]
Student Task (20 min)
TASK 5A Create a list of 8 exam scores (you choose). Write code to:
1. Print the highest and lowest score
2. Print the average (2 decimal places)
3. Print scores in ascending order using bubble_sort()
4. Print how many scores are above 70
TASK 5B You have a list of tuples: student_results = [('Kwame',55),('Esi',82),('Yaw',67)]
Print each student's name and whether they passed (>=50) or failed.
ACTIVITY 6 — Dictionaries
Segment Link: Segments A & B | Time: 50 minutes
Learning Objective: Students can create, update, and traverse dictionaries to model real-world key-
value relationships.
Worked Example 1 — Dictionary Basics
# Creating a dictionary
student = {
'name': 'Kofi Mensah',
'age': 16,
'school': 'Accra High',
'score': 88
}
# Accessing values
print(student['name']) # Kofi Mensah
print([Link]('score', 0)) # 88 (get() avoids KeyError)
# Adding / updating
student['grade'] = 'A' # add new key
student['score'] = 92 # update existing
# Deleting
del student['age']
# Useful methods
print([Link]()) # dict_keys(['name', 'school', 'score', 'grade'])
print([Link]())
print([Link]()) # list of (key, value) tuples
Worked Example 2 — Iterating a Dictionary
scores = {'Ama': 91, 'Kofi': 74, 'Abena': 83, 'Kweku': 67}
# Print each student and their grade
for name, score in [Link]():
if score >= 70:
grade = 'Pass'
else:
grade = 'Fail'
print(f'{name}: {score} -> {grade}')
# Find top scorer
top = max(scores, key=[Link])
print(f'Top scorer: {top} with {scores[top]}')
Worked Example 3 — Grouping Data (Competition Pattern)
# Group students by grade band — very common in competition problems
results = [('Ama',91),('Kofi',74),('Abena',83),('Kweku',55),('Akua',68),
('Yaw',48)]
grade_groups = {'A': [], 'B': [], 'C': [], 'D': [], 'F': []}
for name, score in results:
if score >= 70: grade_groups['A'].append(name)
elif score >= 60: grade_groups['B'].append(name)
elif score >= 50: grade_groups['C'].append(name)
elif score >= 40: grade_groups['D'].append(name)
else: grade_groups['F'].append(name)
for band, students in grade_groups.items():
if students:
print(f'Grade {band}: {", ".join(students)}')
# Output:
# Grade A: Ama, Abena
# Grade B: Kofi, Akua
# Grade C: Kweku
# Grade F: Yaw
Student Task (20 min)
TASK 6A Create a dictionary for 5 students mapping name -> score.
Print: the student with the highest score, the average score,
and a list of students who scored below the average.
TASK 6B Write a function word_count(sentence) that returns a dictionary
mapping each word -> number of times it appears in the sentence.
Test: word_count('the cat sat on the mat the cat')
Expected: {'the':3, 'cat':2, 'sat':1, 'on':1, 'mat':1}
Model Solution — Task 6B
def word_count(sentence):
words = [Link]() # split string into list of words
counts = {}
for word in words:
if word in counts:
counts[word] += 1
else:
counts[word] = 1
return counts
print(word_count('the cat sat on the mat the cat'))
# {'the': 3, 'cat': 2, 'sat': 1, 'on': 1, 'mat': 1}
ACTIVITY 7 — Sets & Combined Data Structures
Segment Link: Segment B (Coding Challenge) | Time: 45 minutes
Learning Objective: Students can use sets for membership and deduplication, and combine lists,
dictionaries, and sets to solve problems.
Worked Example 1 — Set Basics
# Sets: unordered, no duplicates
school_a = {'Ama', 'Kofi', 'Abena', 'Kweku'}
school_b = {'Kofi', 'Akua', 'Yaw', 'Abena'}
# Set operations
print(school_a | school_b) # Union — all students from both schools
print(school_a & school_b) # Intersection — in BOTH schools: {'Kofi','Abena'}
print(school_a - school_b) # Difference — only in school A: {'Ama','Kweku'}
# Membership test (faster than list for large data)
print('Ama' in school_a) # True
print('Yaw' in school_a) # False
# Removing duplicates from a list
raw = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
unique = list(set(raw))
print(unique) # order may vary but all unique
Worked Example 2 — Combined Structures
# Dictionary of lists — students grouped by school
schools = {
'Accra High': [('Ama', 88), ('Kofi', 74)],
'Ridge School':[('Abena', 95), ('Kweku', 61)],
'Legon Prep': [('Akua', 70), ('Yaw', 48)],
}
# Find the top scorer from each school
for school, students in [Link]():
top = max(students, key=lambda x: x[1])
print(f'{school} top scorer: {top[0]} ({top[1]})')
# Find ALL students with score >= 70 across all schools
qualifiers = []
for school, students in [Link]():
for name, score in students:
if score >= 70:
[Link]((name, score, school))
[Link](key=lambda x: x[1], reverse=True)
print('\nQualifiers (ranked):')
for name, score, school in qualifiers:
print(f' {name} ({school}): {score}')
Student Task (20 min)
TASK 7 You have two lists of students who passed different rounds:
round1_pass = ['Ama','Kofi','Abena','Kweku','Akua']
round2_pass = ['Kofi','Abena','Yaw','Ama','Nana']
Using sets, find and print:
1. Students who passed BOTH rounds (qualified for finals)
2. Students who passed Round 1 but NOT Round 2 (eliminated)
3. All unique students across both rounds
4. How many unique students participated in total
Model Solution
round1_pass = {'Ama','Kofi','Abena','Kweku','Akua'}
round2_pass = {'Kofi','Abena','Yaw','Ama','Nana'}
finalists = round1_pass & round2_pass
eliminated = round1_pass - round2_pass
all_unique = round1_pass | round2_pass
print('Finalists:', finalists) # {'Kofi','Abena','Ama'}
print('Eliminated:', eliminated) # {'Kweku','Akua'}
print('Total participants:', len(all_unique)) # 7
ACTIVITY 8 — Leaderboard Builder (Full Competition
Challenge)
Segment Link: Segment B (Coding Challenge — mirrors real competition problem) | Time: 60
minutes
Learning Objective: Students apply ALL data structure skills to build a complete, multi-function
program.
This activity mirrors the style and difficulty of the actual Segment B coding challenge. Students
should work in their competition teams. All code should be commented.
Problem Statement
You are building a competition leaderboard system for an inter-school Python event.
The system must:
1. Store student results: name, school, and scores for 3 segments (A, B, C)
2. Calculate each student's total score (max 75)
3. Assign a rank: Gold (>=60), Silver (>=45), Bronze (>=30), Disqualified (<30)
4. Display a sorted leaderboard (highest total first)
5. Display the top scorer from each school
6. Show how many students from each school qualified (rank != Disqualified)
Starter Code (given to students)
# Competition data — list of tuples: (name, school, seg_a, seg_b, seg_c)
entries = [
('Ama Mensah', 'Accra High', 18, 28, 16),
('Kofi Boateng', 'Accra High', 14, 22, 12),
('Abena Asare', 'Ridge School', 20, 33, 18),
('Kweku Owusu', 'Ridge School', 11, 18, 8),
('Akua Frimpong', 'Legon Prep', 16, 30, 15),
('Yaw Darko', 'Legon Prep', 19, 31, 17),
('Nana Amponsah', 'Accra High', 17, 25, 14),
('Efua Asante', 'Ridge School', 13, 20, 11),
]
# ── YOUR FUNCTIONS GO BELOW ──────────────────────────────────
def calculate_total(seg_a, seg_b, seg_c):
# TODO: return the sum of all three segment scores
pass
def assign_rank(total):
# TODO: return 'Gold', 'Silver', 'Bronze', or 'Disqualified'
pass
def build_leaderboard(entries):
# TODO: return a sorted list of dicts with keys:
# name, school, total, rank
pass
def top_per_school(leaderboard):
# TODO: return a dict mapping school -> top student name & score
pass
def school_qualifiers(leaderboard):
# TODO: return a dict mapping school -> count of non-Disqualified students
pass
# ── MAIN PROGRAM ─────────────────────────────────────────────
# Call your functions and display formatted output
Full Model Solution
def calculate_total(seg_a, seg_b, seg_c):
return seg_a + seg_b + seg_c
def assign_rank(total):
if total >= 60: return 'Gold'
elif total >= 45: return 'Silver'
elif total >= 30: return 'Bronze'
else: return 'Disqualified'
def build_leaderboard(entries):
leaderboard = []
for name, school, a, b, c in entries:
total = calculate_total(a, b, c)
rank = assign_rank(total)
[Link]({
'name': name, 'school': school,
'total': total, 'rank': rank
})
[Link](key=lambda x: x['total'], reverse=True)
return leaderboard
def top_per_school(leaderboard):
top = {}
for student in leaderboard:
school = student['school']
if school not in top: # first occurrence = highest (sorted)
top[school] = student
return top
def school_qualifiers(leaderboard):
counts = {}
for student in leaderboard:
school = student['school']
if school not in counts:
counts[school] = 0
if student['rank'] != 'Disqualified':
counts[school] += 1
return counts
# ── MAIN ─────────────────────────────────────────────────────
lb = build_leaderboard(entries)
print('=' * 55)
print(f"{'RANK':<6}{'NAME':<20}{'SCHOOL':<16}{'TOTAL':>5}{'MEDAL':>8}")
print('=' * 55)
for i, s in enumerate(lb, 1):
print(f"{i:<6}{s['name']:<20}{s['school']:<16}{s['total']:>5}{s['rank']:>8}")
print('\n--- Top Scorer Per School ---')
for school, s in top_per_school(lb).items():
print(f" {school}: {s['name']} ({s['total']} pts)")
print('\n--- Qualifiers Per School ---')
for school, count in school_qualifiers(lb).items():
print(f" {school}: {count} qualifier(s)")
Expected Output
=======================================================
RANK NAME SCHOOL TOTAL MEDAL
=======================================================
1 Abena Asare Ridge School 71 Gold
2 Yaw Darko Legon Prep 67 Gold
3 Ama Mensah Accra High 62 Gold
4 Akua Frimpong Legon Prep 61 Gold
5 Nana Amponsah Accra High 56 Silver
6 Kofi Boateng Accra High 48 Silver
7 Efua Asante Ridge School 44 Bronze
8 Kweku Owusu Ridge School 37 Bronze
--- Top Scorer Per School ---
Ridge School: Abena Asare (71 pts)
Legon Prep: Yaw Darko (67 pts)
Accra High: Ama Mensah (62 pts)
--- Qualifiers Per School ---
Accra High: 3 qualifier(s)
Ridge School: 3 qualifier(s)
Legon Prep: 2 qualifier(s)
ACTIVITY 9 — Presentation & Explanation Drill
Segment Link: Segment C (Presentation) | Time: 40 minutes
Learning Objective: Students can explain their code clearly, justify data structure choices, and answer
technical questions under pressure.
Why This Activity Matters
Segment C is worth 20 marks — the same weight as the individual quiz. Many teams lose points
here not because their code is wrong, but because they cannot explain it. This drill trains that
muscle.
Part 1 — Explain-It-Back (10 min)
Using the Leaderboard Builder from Activity 8, each team member must take one function and
explain it in plain English — as if speaking to someone who has never coded before. No jargon
without definition.
Function What to explain
calculate_total() What goes in, what comes out, why it is a separate function
assign_rank() The logic of the if/elif chain, what happens at the boundaries
build_leaderboard() How a list of dicts is built, what sort() with key= does
top_per_school() Why the first occurrence in a sorted list gives the top scorer
Part 2 — Justify Your Choices (10 min)
For each question below, teams discuss and agree on the best answer before the mock Q&A:
Examiner Question Model Answer Points
Why did you use a dictionary to Keys give O(1) lookup; natural mapping of school name ->
group results by school? data; avoids nested loops.
Why sort using key=lambda x: Dicts have no natural order; lambda extracts the field to sort
x['total'] and not just sort()? by.
What would happen if two students They keep relative order from the original list (stable sort).
had the same total score? Could add name as tiebreaker.
Why use a list of dicts rather than a Dicts are self-documenting — student['name'] is clearer than
list of tuples? student[0].
What is the time complexity of your Python's sort is Timsort: O(n log n) in worst case.
sort?
Part 3 — Mock Panel (20 min)
Teacher acts as judge. Each team presents Activity 8's solution for 5 minutes, then answers 2
surprise questions from the list below. Score using Segment C rubric from the competition brief.
Surprise Question Bank
• Can you walk me through what happens when we run build_leaderboard() step by step?
• If a student scores 0 on all segments, what rank do they get and why?
• How would you change the code to support 5 segments instead of 3?
• What is the difference between a list and a tuple — why did you choose a list here?
• If two students are from the same school, how does top_per_school() decide who wins?
• How would you add a feature to search for a student by name?
• What does reverse=True do in the sort call — what would happen without it?
Self-Assessment Checklist
Criterion Yes Partially Not Yet
I can explain what each function does in plain ☐ ☐ ☐
English
I can justify why I used a dictionary vs a list ☐ ☐ ☐
I can explain how sorting with a lambda key ☐ ☐ ☐
works
I can answer questions about edge cases (empty ☐ ☐ ☐
list, tied scores)
My team shared the presentation fairly between ☐ ☐ ☐
members
Year 11 Python Competition — Full Learning Plan | All activities © Teacher Resource