Codebash 100 Python Challenges
Codebash 100 Python Challenges
uk
FREE RESOURCE
100 Python
Programming
Challenges
Ready-to-use classroom problems for Computer Science
teachers
[Link] · 1 / 87
How to Use This Pack
Each challenge includes a problem statement (written in plain language), an example showing
expected input and output, hints for differentiation, mark scheme notes, and an extension task
for students who finish early.
The hints column can be withheld from more confident students. Mark scheme notes describe
what a correct solution must achieve - they are intentionally brief so this document remains
usable as a classroom handout.
Foundation: Basic syntax, input/output, selection, and loops. Suitable for KS3 and secondary
foundation learners.
Intermediate: Functions, lists, strings, OOP basics, and classic algorithms. Core secondary and lower
A-Level.
Applied: File I/O, error handling, data structures, recursion, and applied algorithms. Upper secondary
and A-Level.
Stretch Challenges: Multi-part problems combining multiple skills. A-Level standard. Maps to NEA
complexity requirements.
These challenges are available on CodeBash as interactive auto-marked tasks - run them
in class, track student progress, and see exactly which concepts need more support.
Free trial at [Link] · No credit card required
[Link] · 2 / 87
Foundation
Basic syntax, input/output, selection, and loops. Suitable for KS3 and secondary foundation learners.
PROBLEM
Write a program that asks the user for their name and displays a personalised greeting.
EXAMPLE
HINTS
Use input() to collect the name. Use an f-string to build the message.
MARK SCHEME
Correctly uses input(). Outputs a greeting that includes the name entered.
EXTENSION
Ask for first and last name separately. Display "Hello, [first] [last]!"
TEACHER NOTES
Works well as a first ever Python task. Students often forget to store the return value of input() in
a variable - a useful misconception to address early.
[Link] · 3 / 87
Challenge 2 Age Calculator
PROBLEM
Ask the user for the year they were born. Calculate and display their age this year.
EXAMPLE
HINTS
Use int() to convert input. Subtract birth year from the current year (2026).
MARK SCHEME
Correct use of int(). Correct subtraction. Output includes the calculated age.
EXTENSION
Ask for birth month and day. Give a more precise age in years and months.
TEACHER NOTES
Introduces type conversion naturally. Students are often surprised that input() always returns a
string - set this expectation before they run into the error.
PROBLEM
Ask for the length and width of a rectangle. Display its area and perimeter.
EXAMPLE
Enter length: 8
Enter width: 5
Area: 40
Perimeter: 26
HINTS
Area = length x width. Perimeter = 2 x (length + width). Use float() for inputs.
MARK SCHEME
Correct formulae for both area and perimeter. Both values displayed clearly.
EXTENSION
TEACHER NOTES
A good consolidation task after covering variables and arithmetic operators. Encourage students
to use descriptive variable names rather than single letters.
[Link] · 4 / 87
Challenge 4 Odd or Even
PROBLEM
Ask the user for a whole number. Tell them whether it is odd or even.
EXAMPLE
Enter a number: 7
7 is odd.
HINTS
MARK SCHEME
Correct use of modulo. Both cases handled. Output includes the original number.
EXTENSION
TEACHER NOTES
Introduces the modulo operator, which many students encounter for the first time here. Worth
pausing to explain what remainder means before students start coding.
PROBLEM
EXAMPLE
HINTS
Use float() for input. Apply the formula. Round to 1 decimal place using round().
MARK SCHEME
Correct formula. Output shows both values with units. Handles decimal input.
EXTENSION
TEACHER NOTES
Good for practising arithmetic and rounding. Students who finish quickly benefit from the
extension, which introduces simple selection.
[Link] · 5 / 87
Challenge 6 Password Checker
PROBLEM
Ask the user to enter a password. Tell them if it is strong or weak. Rules: at least 8
characters, contains at least one number, contains at least one uppercase letter.
EXAMPLE
HINTS
Use len() for length. Use any([Link]() for c in password) to check for a digit.
MARK SCHEME
All three rules checked independently. Specific feedback given for each failure. Passes when all
three are met.
EXTENSION
TEACHER NOTES
Students often try to use a single long if-statement instead of checking each rule separately.
Encourage checking each condition independently so feedback is specific.
[Link] · 6 / 87
Challenge 7 Times Table
PROBLEM
Ask the user for a number. Display the times table for that number up to 12.
EXAMPLE
Enter a number: 6
6 x 1 = 6
6 x 2 = 12
...
6 x 12 = 72
HINTS
MARK SCHEME
Correct loop range. Correct calculation. All 12 lines displayed in correct format.
EXTENSION
Ask the user how far they want the table to go (e.g. up to 20).
TEACHER NOTES
A classic first for loop task. Students often write range(1, 12) and miss the 12 times entry - worth
discussing how range() works before they start.
[Link] · 7 / 87
Challenge 8 Number Guessing Game
PROBLEM
Generate a random number between 1 and 10. Ask the user to guess it. Tell them if they
are correct, too high, or too low. Keep asking until they get it right.
EXAMPLE
HINTS
Use import random and [Link](1, 10). Use a while loop. Count guesses with a variable.
MARK SCHEME
Random number generated. Loop continues until correct. High/low feedback given. Guess count
displayed.
EXTENSION
TEACHER NOTES
This task works well once students have covered loops and selection. Some students struggle to
understand that the random number must be generated before the loop begins, not inside it.
[Link] · 8 / 87
Challenge 9 FizzBuzz
PROBLEM
Print the numbers from 1 to 100. For multiples of 3 print Fizz, for multiples of 5 print Buzz,
for multiples of both print FizzBuzz.
EXAMPLE
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz...
HINTS
MARK SCHEME
Correct output for all three cases. FizzBuzz case handled before the individual checks.
EXTENSION
TEACHER NOTES
FizzBuzz is deliberately simple but tests whether students understand order of conditions in if/elif
chains. Students who check 3 and 5 separately first will fail on 15 - worth discussing why as a
class.
[Link] · 9 / 87
Challenge 10 Shopping Basket Total
PROBLEM
Ask the user to enter item prices one at a time. When they type 'done', display the total
and the number of items.
EXAMPLE
HINTS
Use a while loop. Convert input to float. Accumulate total with +=.
MARK SCHEME
Loop exits on 'done'. Correct total and item count. Handles at least one item entered.
EXTENSION
TEACHER NOTES
A natural use of indefinite iteration. Students sometimes struggle with the sentinel value pattern
- writing the loop condition and the string comparison in the same step can cause confusion.
[Link] · 10 / 87
Challenge 11 Grade Classifier
PROBLEM
Ask for a student's exam score (0-100). Display the corresponding grade: 90-100=A*,
80-89=A, 70-79=B, 60-69=C, 50-59=D, below 50=U.
EXAMPLE
Enter score: 85
Grade: A
HINTS
Use elif for each range. Handle invalid input (below 0 or above 100).
MARK SCHEME
All six grades correctly assigned. Invalid input handled with an error message.
EXTENSION
Ask for scores in five subjects. Display the average and overall grade.
TEACHER NOTES
Students often write overlapping conditions, for example if score >= 80 and if score >= 70
without elif. Walk through what happens when a score of 85 hits each line - it helps them see
why elif matters.
Challenge 12 Factorial
PROBLEM
Ask the user for a positive integer. Calculate and display its factorial.
EXAMPLE
Enter a number: 5
5! = 120
HINTS
MARK SCHEME
EXTENSION
TEACHER NOTES
A good introduction to accumulator patterns. Many students initialise their result variable at 0
instead of 1 - worth predicting what will happen before they run it.
[Link] · 11 / 87
Challenge 13 Countdown Timer
PROBLEM
Ask the user for a starting number. Count down to zero, displaying each number.
EXAMPLE
Start from: 5
5
4
3
2
1
Blast off!
HINTS
MARK SCHEME
All numbers displayed in correct order. 'Blast off!' shown at end. Handles start of 0.
EXTENSION
TEACHER NOTES
Useful for consolidating loops. Students using range() often forget that range(n, 0, -1) excludes
0, so 'Blast off!' must be handled separately.
[Link] · 12 / 87
Challenge 14 Sum of Digits
PROBLEM
Ask the user for a positive integer. Calculate the sum of its digits.
EXAMPLE
HINTS
Convert to a string and iterate through characters. Convert each character back to int.
MARK SCHEME
Correct sum for any positive integer. Handles single-digit input correctly.
EXTENSION
Keep summing the digits until a single digit remains (digital root).
TEACHER NOTES
This task introduces the idea of treating a number as a sequence of characters. Students who
are comfortable with loops often find this satisfying because it combines two ideas they already
know.
PROBLEM
EXAMPLE
HINTS
Use a list indexed from 0. Index 0 can store an empty string or a default.
MARK SCHEME
Correct word for all nine numbers. Handles input outside 1-9 with an error message.
EXTENSION
TEACHER NOTES
A gentle introduction to using lists as lookup tables. Students who use if/elif chains for all nine
cases have solved it correctly but should be shown the list approach as a cleaner alternative.
[Link] · 13 / 87
Challenge 16 Average Calculator
PROBLEM
Ask the user to enter a series of numbers, one per line. When they type 'done', display the
average.
EXAMPLE
HINTS
MARK SCHEME
Correct average. Handles one number entered. Handles 'done' as first input gracefully.
EXTENSION
TEACHER NOTES
Common errors include dividing total by count before the loop ends, or failing to handle the case
where no numbers are entered. Both make good discussion points.
[Link] · 14 / 87
Challenge 17 Palindrome Checker
PROBLEM
Ask the user for a word. Tell them whether it is a palindrome (reads the same forwards and
backwards).
EXAMPLE
HINTS
MARK SCHEME
EXTENSION
Handle phrases (remove spaces and punctuation before checking). 'A man a plan a canal
Panama' should return palindrome.
TEACHER NOTES
Introduces string slicing. Students who check individual characters in a loop also get a working
solution - praise the approach and then show how slice notation compresses it.
PROBLEM
Simulate 100 coin tosses. Count and display the number of heads and tails.
EXAMPLE
Heads: 52
Tails: 48
HINTS
MARK SCHEME
Exactly 100 tosses. Both results counted correctly. Totals add to 100.
EXTENSION
Ask the user how many tosses to simulate. Display results as a percentage.
TEACHER NOTES
A fun entry point for the random module. Students enjoy seeing that results vary each run and
this can prompt a brief discussion about pseudorandom number generation.
[Link] · 15 / 87
Challenge 19 BMI Calculator
PROBLEM
Ask for weight (kg) and height (m). Calculate and display BMI and the category. Formula:
BMI = weight / (height x height) Categories: Below 18.5=Underweight, 18.5-24.9=Healthy,
25-29.9=Overweight, 30+=Obese.
EXAMPLE
HINTS
MARK SCHEME
Correct formula. All four categories correct. Output shows BMI value and category.
EXTENSION
TEACHER NOTES
Consolidates float input and elif chains. Some students square the height using ** 2 which is fine
- worth acknowledging both approaches.
[Link] · 16 / 87
Challenge 20 Number Pyramid
PROBLEM
Ask the user for a number n. Print a right-angled triangle of numbers n rows tall.
EXAMPLE
n=4:
1
1 2
1 2 3
1 2 3 4
HINTS
Outer loop for rows, inner loop for numbers in each row. Use end=' ' in print().
MARK SCHEME
EXTENSION
TEACHER NOTES
Introduces nested loops. Students need to understand that the inner loop range depends on the
outer loop variable - draw the structure on the board before they attempt it.
[Link] · 17 / 87
Challenge 21 Leap Year Checker
PROBLEM
Ask the user for a year. Tell them whether it is a leap year. Rules: divisible by 4, except
centuries, unless divisible by 400.
EXAMPLE
HINTS
MARK SCHEME
EXTENSION
Display all leap years between two years entered by the user.
TEACHER NOTES
A good test of nested or compound conditions. Test students with 1900 and 2000 specifically -
those are the edge cases that catch out most solutions.
PROBLEM
Ask the user for a sentence. Display the sentence with the words in reverse order.
EXAMPLE
HINTS
Use .split() to turn the sentence into a list. Use [::-1] to reverse. Use ' '.join() to reassemble.
MARK SCHEME
Words in correct reverse order. Handles single words. Handles extra spaces.
EXTENSION
TEACHER NOTES
Introduces three important string methods in one task. Students who use a loop to reverse the
list are working correctly - show them the slice notation as an alternative after.
[Link] · 18 / 87
Challenge 23 Multiplication Quiz
PROBLEM
Generate 10 random multiplication questions (numbers 1-12). Mark each answer right or
wrong. Display the final score out of 10.
EXAMPLE
What is 7 x 8? 56
Correct!
What is 3 x 9? 25
Wrong! The answer was 27.
...
You scored 8 out of 10.
HINTS
Use [Link](1, 12). Use a loop. Compare user input (converted to int) with the correct
answer.
MARK SCHEME
EXTENSION
TEACHER NOTES
Students engage well with this task because the output is interactive. Watch out for students
comparing a string input directly with an integer answer - int() conversion is a common omission.
[Link] · 19 / 87
Challenge 24 Currency Converter
PROBLEM
Ask the user for an amount in pounds. Display the equivalent in euros and US dollars using
fixed conversion rates of your choice.
EXAMPLE
HINTS
Define conversion rates as variables at the top. Multiply the amount by each rate.
MARK SCHEME
Correct calculations for both currencies. Symbols displayed. Handles decimal input.
EXTENSION
Let the user choose which currency to convert from and to.
TEACHER NOTES
A straightforward consolidation task. Encourage students to define the rates as named constants
at the top of their program rather than hardcoding them inside the calculation.
PROBLEM
Ask the user for a positive integer. Tell them whether it is prime.
EXAMPLE
Enter a number: 17
17 is prime.
HINTS
A prime has no factors other than 1 and itself. Check divisibility from 2 up to the square root of
the number.
MARK SCHEME
Correct result for primes and non-primes. Handles 1 (not prime) and 2 (prime) correctly.
EXTENSION
TEACHER NOTES
Students often check up to n-1, which works but is inefficient. Introduce the square root
optimisation as an extension discussion for stronger students.
[Link] · 20 / 87
Intermediate
Functions, lists, strings, OOP basics, and classic algorithms. Core secondary and lower A-Level.
PROBLEM
Ask the user for a sentence. Count and display the number of vowels.
EXAMPLE
HINTS
MARK SCHEME
All five vowels counted (case-insensitive). Correct count for any input.
EXTENSION
TEACHER NOTES
Good for consolidating iteration over strings. Students who check .lower() on the character
before comparing against a single-case vowel string show good thinking.
[Link] · 21 / 87
Challenge 27 List Maximum and Minimum
PROBLEM
Ask the user to enter 10 numbers. Display the largest and smallest without using Python's
built-in max() or min() functions.
EXAMPLE
HINTS
Store in a list. Set initial highest/lowest to the first element. Compare each subsequent element.
MARK SCHEME
Does not use built-in max/min. Correct values identified for any 10 numbers.
EXTENSION
TEACHER NOTES
The constraint on not using built-ins is important - it forces students to think about the algorithm.
Students who initialise their tracker at 0 will fail if all numbers are negative.
[Link] · 22 / 87
Challenge 28 Student Grade Book
PROBLEM
Ask the teacher to enter student names and scores. When they type 'done', display each
student with their grade, the class average, and the top scorer.
EXAMPLE
HINTS
Use two parallel lists or a list of tuples. Calculate average from accumulated total.
MARK SCHEME
Names and grades stored and displayed. Average calculated correctly. Top scorer identified.
EXTENSION
TEACHER NOTES
This task works well after students have learned lists and loops. Using two parallel lists versus a
list of tuples is worth discussing as a design choice.
[Link] · 23 / 87
Challenge 29 Caesar Cipher
PROBLEM
Encrypt a message using the Caesar cipher. Ask for the message and the shift value.
EXAMPLE
Message: hello
Shift: 3
Encrypted: khoor
HINTS
Use ord() and chr(). Handle wrap-around from z back to a using modulo.
MARK SCHEME
Correct encryption for all lowercase letters. Non-letter characters unchanged. Wrap-around
handled.
EXTENSION
TEACHER NOTES
Links well with theory lessons on encryption. The wrap-around is the tricky part - students who
get most letters right but fail on x, y, z have probably missed the modulo.
[Link] · 24 / 87
Challenge 30 Word Frequency Counter
PROBLEM
Ask the user for a sentence. Display how many times each unique word appears.
EXAMPLE
Enter a sentence: the cat sat on the mat near the cat
the: 3
cat: 2
sat: 1
HINTS
Use a dictionary. Use .split() to get words. Loop and increment counts.
MARK SCHEME
Correct counts for all words. Case-insensitive. All unique words displayed.
EXTENSION
TEACHER NOTES
An ideal first dictionary task. Students who use a list and count occurrences are working harder
than they need to - this is a good moment to motivate why dictionaries exist.
PROBLEM
EXAMPLE
HINTS
Use [Link]() for the computer's move. Track wins and losses across rounds.
MARK SCHEME
EXTENSION
TEACHER NOTES
Students enjoy this task. The condition logic for all nine combinations is the main challenge -
encourage them to map out all possible matchups before coding.
[Link] · 25 / 87
Challenge 32 Function: Is Prime
PROBLEM
Write a function is_prime(n) that returns True if n is prime, False otherwise. Use it to print all
prime numbers up to 100.
EXAMPLE
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
HINTS
MARK SCHEME
EXTENSION
TEACHER NOTES
Works well as a first functions task because the function has a clear, testable purpose. Students
who print inside the function rather than returning a value need guidance on the return concept.
PROBLEM
EXAMPLE
How many? 8
[0, 1, 1, 2, 3, 5, 8, 13]
HINTS
Start with [0, 1]. Each subsequent number is the sum of the two before it.
MARK SCHEME
Correct sequence. Function returns a list. Handles n=1 and n=2 correctly.
EXTENSION
TEACHER NOTES
Check that students handle n=1 (returns [0]) and n=2 (returns [0, 1]) as edge cases. The
extension to recursion works well as a lead-in to later recursive challenges.
[Link] · 26 / 87
Challenge 34 ATM Simulator
PROBLEM
Simulate an ATM. Start with a balance of 500. Allow the user to: check balance, deposit,
withdraw, or quit. Validate that withdrawals do not exceed the balance.
EXAMPLE
1. Check balance
2. Deposit
3. Withdraw
4. Quit
Choice: 3
Withdraw: 600
Insufficient funds.
HINTS
Use a while loop with a menu. Convert amounts to float. Check balance before allowing
withdrawal.
MARK SCHEME
All four options work correctly. Validation prevents overdraft. Loop continues until quit.
EXTENSION
Set a daily withdrawal limit of 300. Track total withdrawn in the current session.
TEACHER NOTES
A good structured task that requires combining loops, functions, and conditionals. Students who
hard-code the menu options into a single block of code can be encouraged to break it into
functions.
[Link] · 27 / 87
Challenge 35 String Statistics
PROBLEM
Write a function that takes a string and returns: length, number of words, number of
vowels, and number of uppercase letters.
EXAMPLE
HINTS
Use len() for length. Use .split() for word count. Loop through characters for vowels and
uppercase.
MARK SCHEME
Correct values for all four statistics. Function takes a string parameter and returns all results.
EXTENSION
TEACHER NOTES
A useful consolidation of string methods in one task. Some students return only one value from
the function - discuss tuples and multiple return values as appropriate for your class.
PROBLEM
EXAMPLE
HINTS
Use two lists: one for values, one for symbols. Work from the largest value down.
MARK SCHEME
Correct conversion for all values 1-3999. Handles subtractive notation (IV, IX, XL, XC, CD, CM).
EXTENSION
TEACHER NOTES
The subtractive notation cases (IV, IX etc.) trip up students who only map single symbols. Walk
through IV=4 before they start and ask them to think about how to represent it.
[Link] · 28 / 87
Challenge 37 Stack Implementation
PROBLEM
Implement a stack using a list. Provide push, pop, peek, and is_empty operations as
functions.
EXAMPLE
HINTS
A stack is Last In, First Out. Use [Link]() for push and [Link]() for pop.
MARK SCHEME
All four operations work correctly. pop() and peek() handle empty stack gracefully.
EXTENSION
Use your stack to check if brackets in a string are balanced, e.g. {[()]} is balanced.
TEACHER NOTES
Best taught alongside theory content on stacks and queues. Students often understand the
concept easily but struggle to connect it to code - the append/pop mapping is worth making
explicit.
[Link] · 29 / 87
Challenge 38 Queue Implementation
PROBLEM
Implement a queue using a list. Provide enqueue, dequeue, peek, and is_empty operations.
EXAMPLE
HINTS
A queue is First In, First Out. Enqueue to the back, dequeue from the front.
MARK SCHEME
Correct FIFO behaviour. Empty queue handled gracefully on dequeue and peek.
EXTENSION
Simulate a printer queue: add jobs, process them in order, display the status.
TEACHER NOTES
Pair this with challenge 37 for a theory and programming double lesson. The printer queue
extension maps the abstract structure to a real-world use case that students can reason about.
PROBLEM
Write a function that takes two words and returns True if they are anagrams of each other.
EXAMPLE
HINTS
Sort the letters of both words and compare. Use .lower() before sorting.
MARK SCHEME
EXTENSION
TEACHER NOTES
A neat task that demonstrates the power of sorting as a problem-solving technique. Students
who compare character counts in a dictionary also get a working and arguably more efficient
solution.
[Link] · 30 / 87
Challenge 40 Number Base Converter
PROBLEM
Write a program that converts a decimal number to binary, octal, and hexadecimal -
without using Python's built-in bin(), oct(), or hex() functions.
EXAMPLE
HINTS
Use repeated division by the target base. Collect remainders in reverse order.
MARK SCHEME
Correct conversion for all three bases using the division algorithm. Handles 0.
EXTENSION
Convert in the other direction: binary, octal, and hex inputs to decimal.
TEACHER NOTES
Works very well alongside binary and hexadecimal theory content. The restriction on built-in
functions forces students to understand the algorithm rather than delegating it to Python.
[Link] · 31 / 87
Challenge 41 Highest Common Factor
PROBLEM
Write a function to find the highest common factor (HCF) of two numbers using the
Euclidean algorithm.
EXAMPLE
HINTS
MARK SCHEME
Correct HCF for all valid inputs. Implements the Euclidean algorithm rather than brute force.
EXTENSION
TEACHER NOTES
A good introduction to algorithm implementation. Students who use brute force (checking all
numbers from 1 to n) arrive at a correct answer but should be shown why the Euclidean
approach is better.
PROBLEM
Take a sentence and scramble the letters within each word, keeping the first and last letters
in place.
EXAMPLE
HINTS
For each word, keep index 0 and -1 in place. Shuffle the middle using [Link]().
MARK SCHEME
First and last letters unchanged. Middle letters randomised. Words of 3 or fewer characters left
unchanged.
EXTENSION
Ask the user if they can still read the scrambled sentence. Build a short quiz around it.
TEACHER NOTES
An engaging task with a fun result. Students often forget to handle short words (3 characters or
fewer) correctly. Testing with a single-letter word is a good edge case to discuss.
[Link] · 32 / 87
Challenge 43 Matrix Addition
PROBLEM
Create two 3x3 matrices as 2D lists. Write a function to add them and display the result.
EXAMPLE
HINTS
Use nested loops to iterate over rows and columns. Add corresponding elements.
MARK SCHEME
Correct element-wise addition. Result displayed in grid format. Function takes two matrices as
parameters.
EXTENSION
TEACHER NOTES
Use this task to introduce 2D lists. Students benefit from seeing a 3x3 grid drawn on the board
alongside the nested list representation before they start coding.
[Link] · 33 / 87
Challenge 44 Bank Account Class
PROBLEM
Create a BankAccount class with attributes for account holder name and balance. Add
methods for deposit, withdraw, and display balance. Validate that withdrawals do not
exceed the balance.
EXAMPLE
HINTS
MARK SCHEME
Class defined with __init__. Correct deposit/withdraw methods. Validation prevents negative
balance.
EXTENSION
TEACHER NOTES
A good first OOP task because the real-world analogy is strong. Students often confuse the class
definition with creating an object - make sure they write and run the instantiation line in the
same program.
[Link] · 34 / 87
Challenge 45 Linear Search
PROBLEM
Write a function linear_search(lst, target) that returns the index of the target or -1 if not
found. Test it with a list of names.
EXAMPLE
HINTS
Loop through each element with its index. Return the index as soon as a match is found.
MARK SCHEME
Searches element by element. Returns correct index or -1. Does not use Python's .index()
method.
EXTENSION
Count the number of comparisons made and display it alongside the result.
TEACHER NOTES
Pair with theory on searching algorithms. The comparison counter in the extension leads
naturally into a discussion of efficiency and Big O notation at A-Level.
[Link] · 35 / 87
Challenge 46 Binary Search
PROBLEM
Write a function binary_search(lst, target) for a sorted list. Return the index or -1 if not
found.
EXAMPLE
HINTS
Use low, high, and mid pointers. Compare target with middle element each iteration.
MARK SCHEME
Correct divide-and-conquer approach. Returns correct index or -1. Requires sorted input.
EXTENSION
TEACHER NOTES
Best done after challenge 45 (linear search) so students can compare the two. Many students
find the pointer logic confusing at first - tracing through a small example on paper before coding
helps.
[Link] · 36 / 87
Challenge 47 Bubble Sort
PROBLEM
Implement bubble sort to sort a list of numbers in ascending order. Do not use Python's
built-in sort.
EXAMPLE
HINTS
Use nested loops. In each pass, compare adjacent elements and swap if in the wrong order.
MARK SCHEME
Correct implementation. Sorted in ascending order. Works for any length list.
EXTENSION
TEACHER NOTES
Students who understand the concept but write incorrect index logic benefit from tracing
through one full pass manually before coding. The early-exit extension is excellent for
demonstrating best-case complexity.
PROBLEM
EXAMPLE
HINTS
For each element, find its correct position in the already-sorted left portion and insert it.
MARK SCHEME
Correct algorithm. Alphabetical order produced. Works for any length list.
EXTENSION
TEACHER NOTES
Using strings rather than numbers gives this a distinct flavour from bubble sort. Students
discover that Python compares strings lexicographically by default, which is worth discussing.
[Link] · 37 / 87
Challenge 49 Merge Sort
PROBLEM
EXAMPLE
HINTS
Split the list in half recursively until single elements remain. Merge sorted halves back together.
MARK SCHEME
EXTENSION
Count the number of comparisons made. Compare with bubble sort on the same data.
TEACHER NOTES
This is the first genuinely recursive task in this tier. Students who have not seen recursion before
may need challenge 68 (Tower of Hanoi) introduced first, or a brief class discussion of recursive
thinking.
PROBLEM
Write a function that generates a username from a first name, last name, and birth year.
Format: first letter of first name + full last name + last two digits of year, all lowercase.
EXAMPLE
HINTS
Use string indexing and slicing. Use .lower() for lowercase. Use str() for the year.
MARK SCHEME
Correct format produced. All lowercase. Handles names with mixed capitalisation.
EXTENSION
Check a list of existing usernames and add a number suffix if the generated name is already
taken.
TEACHER NOTES
A nice applied string manipulation task. The extension gives faster students an interesting
problem that introduces list membership testing.
[Link] · 38 / 87
Challenge 51 Roman Numeral Validator
PROBLEM
EXAMPLE
HINTS
Valid Roman numerals follow specific ordering and repetition rules. Check for invalid patterns.
MARK SCHEME
EXTENSION
TEACHER NOTES
A challenge that tests careful rule-following more than syntax knowledge. Students benefit from
listing the rules explicitly before coding, rather than trying to encode them on the fly.
[Link] · 39 / 87
Challenge 52 Temperature Statistics
PROBLEM
Ask the user to enter daily temperatures for a week (7 values). Display the average, hottest
day, coldest day, and number of days above average.
EXAMPLE
HINTS
Store temperatures in a list. Calculate average first, then use loops for the other stats.
MARK SCHEME
Correct average. Correct min/max with day number identified. Correct above-average count.
EXTENSION
TEACHER NOTES
Students often calculate the above-average count before calculating the average, which causes
issues. Encourage them to plan the order of their calculations before writing code.
[Link] · 40 / 87
Challenge 53 Postcode Validator
PROBLEM
Write a function that checks if a UK postcode is in a valid format (e.g. SW1A 2AA).
EXAMPLE
HINTS
A valid UK postcode has a specific letter/digit pattern. Check length and character positions.
MARK SCHEME
Accepts valid UK postcodes. Rejects invalid formats. Handles uppercase and lowercase input.
EXTENSION
Extract and display the outward code (first part) from a valid postcode.
TEACHER NOTES
A good task for discussing the complexity of real-world data validation. UK postcodes have
several valid formats - discuss with students how much complexity to handle and why full
validation is hard.
[Link] · 41 / 87
Challenge 54 Hangman
PROBLEM
Implement a text-based Hangman game. Choose a random word from a predefined list.
Give the player 6 lives.
EXAMPLE
Word: _ _ _ _ _
Guess a letter: e
Word: _ e _ _ _
Lives remaining: 6
HINTS
MARK SCHEME
Word displayed as underscores. Letters revealed on correct guess. Lives decremented on wrong
guess. Win/lose detected.
EXTENSION
Display an ASCII art gallows that builds progressively as lives are lost.
TEACHER NOTES
Students enjoy this task and it combines several skills naturally. Common issues include not
checking for repeated guesses and not detecting the win condition once the last letter is
revealed.
[Link] · 42 / 87
Challenge 55 Contact Book
PROBLEM
Build a contact book using a dictionary. Allow the user to add, search, update, and delete
contacts (name and phone number).
EXAMPLE
1. Add contact
2. Search
3. Update
4. Delete
5. Quit
HINTS
Use a dictionary where the key is the name. Show a menu with a while loop.
MARK SCHEME
All four operations work. Search returns result or 'not found'. Handles empty contact book.
EXTENSION
TEACHER NOTES
A good consolidation task for dictionaries. The file persistence extension bridges into the Applied
tier and works well for more confident students who finish early.
[Link] · 43 / 87
Applied
File I/O, error handling, data structures, recursion, and applied algorithms. Upper secondary and A-
Level.
PROBLEM
Write a program that reads a text file and displays the total word count, line count, and the
five most common words.
EXAMPLE
File: [Link]
Lines: 42
Words: 387
Top 5 words: the(28), a(21), and(19), he(15), was(12)
HINTS
Use open() and readlines(). Split each line into words. Use a dictionary to count frequencies.
MARK SCHEME
Correct file read with error handling. Correct word and line counts. Top 5 words identified and
sorted.
EXTENSION
Ignore common stop words (the, a, is, in, and...) from the top 5.
TEACHER NOTES
Introduce file I/O carefully before this task. Provide a sample text file for students to test with -
having them create their own first wastes time and leads to inconsistent results.
[Link] · 44 / 87
Challenge 57 CSV Reader
PROBLEM
Read a CSV file of student names and marks. Display each student's name and grade.
Calculate the class average.
EXAMPLE
Alice, 78 -> B
Bob, 91 -> A*
Class average: 84.5
HINTS
Use open() and split(',') or the csv module. Strip whitespace from values.
MARK SCHEME
Correct file read. Grade assigned from mark. Class average calculated correctly.
EXTENSION
TEACHER NOTES
Provide a sample CSV file. Students who use the csv module rather than manual splitting are
doing something admirable and worth acknowledging.
[Link] · 45 / 87
Challenge 58 High Score File
PROBLEM
Write a game score system. Save the player's name and score to a file. Each time the
program runs, load existing scores and display the top 3.
EXAMPLE
HINTS
Use append mode ('a') to add scores. Read all scores to find the top 3.
MARK SCHEME
Correct file write (append). Correct file read. Top 3 identified and displayed. Handles missing file
on first run.
EXTENSION
TEACHER NOTES
The missing file on first run is the most commonly missed edge case. Ask students to test their
program in a fresh folder where the file does not exist yet.
[Link] · 46 / 87
Challenge 59 Error-Handled Calculator
PROBLEM
Build a calculator that handles division by zero, invalid input, and unknown operations
gracefully using try/except.
EXAMPLE
HINTS
Use try/except around float conversion and the calculation. Check for division by zero separately.
MARK SCHEME
All four operations work. Division by zero handled. Non-numeric input handled. Unknown
operator handled.
EXTENSION
TEACHER NOTES
Good for introducing exception handling. Students often catch all errors with a bare except
clause - discuss why catching specific exceptions is better practice.
[Link] · 47 / 87
Challenge 60 Log File Analyser
PROBLEM
Given a log file where each line starts with [ERROR], [INFO], or [WARNING], count each type
and display the three most recent errors.
EXAMPLE
INFO: 142
WARNING: 31
ERROR: 8
Most recent errors:
[ERROR] Database connection failed
[ERROR] Timeout on request
[ERROR] Invalid user ID
HINTS
Read lines and check the start of each. Store error lines in a list.
MARK SCHEME
Correct counts for all three types. Last three errors identified. Handles missing file.
EXTENSION
TEACHER NOTES
Provide a sample log file for students to use. This task links well with real-world discussions
about how developers monitor software in production.
[Link] · 48 / 87
Challenge 61 Student Records (OOP)
PROBLEM
Create a Student class with name, age, and a list of grades. Add methods to add a grade,
calculate the average, and return the highest grade. Create three students and display their
details.
EXAMPLE
HINTS
Define __init__ with name, age, and an empty grades list. Add methods that operate on
[Link].
MARK SCHEME
Class with __init__. Correct methods. Grades list maintained and updated correctly.
EXTENSION
Create a Classroom class that holds a list of Student objects. Add a method to return the top
student.
TEACHER NOTES
Students who have done challenge 44 (BankAccount) will find this more comfortable. Encourage
students to think about what data belongs in the class and what belongs outside it.
[Link] · 49 / 87
Challenge 62 Animal Hierarchy (Inheritance)
PROBLEM
Create an Animal base class with name and sound. Create Dog and Cat subclasses that
override a speak() method. Create a GuideDog subclass of Dog that adds a guide() method.
EXAMPLE
dog = Dog('Rex')
[Link]() -> Rex says: Woof!
guide_dog = GuideDog('Buddy')
guide_dog.guide() -> Buddy is guiding their owner.
HINTS
MARK SCHEME
EXTENSION
Add a __str__ method to each class. Create a mixed list and call speak() on each (polymorphism).
TEACHER NOTES
The GuideDog inheriting from Dog (rather than directly from Animal) is the key concept here.
Draw the inheritance hierarchy on the board and ask students to identify which methods each
class has access to.
[Link] · 50 / 87
Challenge 63 Linked List
PROBLEM
Implement a singly linked list with Node and LinkedList classes. Provide methods to append,
prepend, delete by value, and display.
EXAMPLE
HINTS
Node has value and next attributes. LinkedList has a head attribute. Traverse using a while loop.
MARK SCHEME
Node class with value and next pointer. Correct append and prepend. Delete handles missing
value. Display traverses correctly.
EXTENSION
TEACHER NOTES
Teach this alongside theory on linked lists. Students benefit from drawing boxes and arrows on
paper before coding. The delete method is the hardest part - the edge case of deleting the head
node catches many students out.
[Link] · 51 / 87
Challenge 64 Binary Search Tree
PROBLEM
Implement a binary search tree with insert, search, and in-order traversal.
EXAMPLE
Insert: 5, 3, 7, 1, 4
In-order: [1, 3, 4, 5, 7]
Search 4: Found
HINTS
Each node has value, left, and right. Insert by comparing with current node value.
MARK SCHEME
Correct insertion maintaining BST property. Search returns True/False. In-order traversal
produces sorted output.
EXTENSION
TEACHER NOTES
In-order traversal is recursive and students who have not seen recursion before will struggle.
Challenge 49 (merge sort) or challenge 68 (Tower of Hanoi) make useful prerequisites.
[Link] · 52 / 87
Challenge 65 Hash Table
PROBLEM
Implement a hash table with a simple hash function, insert, and lookup. Handle collisions
using chaining.
EXAMPLE
[Link]('name', 'Alice')
[Link]('name') -> 'Alice'
[Link]('age') -> None
HINTS
MARK SCHEME
Correct hash function. Insert stores key-value pair. Lookup returns correct value. Collision
handling implemented.
EXTENSION
TEACHER NOTES
Links well with theory on hashing and collision handling. Walk through what happens when two
keys hash to the same index before students write the collision handling code.
[Link] · 53 / 87
Challenge 66 Graph (Adjacency List)
PROBLEM
Represent a graph of cities and roads using an adjacency list (dictionary of lists). Add
methods to add a node, add an edge, and display all connections.
EXAMPLE
graph.add_edge('London', 'Brighton')
[Link]()
London: [Brighton]
Brighton: [London]
HINTS
Use a dictionary where keys are node names and values are lists of connected nodes.
MARK SCHEME
Correct adjacency list structure. Bidirectional edges added. Display shows all connections clearly.
EXTENSION
TEACHER NOTES
Pairs well with theory on graph data structures. Students often forget to add the reverse edge for
an undirected graph - ask them to think about what happens if you drive from London to
Brighton but cannot come back.
[Link] · 54 / 87
Challenge 67 Dijkstra's Shortest Path
PROBLEM
Using a weighted graph as an adjacency list, implement Dijkstra's algorithm to find the
shortest path between two nodes.
EXAMPLE
HINTS
Use a visited set and a distances dictionary. Always process the unvisited node with the smallest
known distance.
MARK SCHEME
Correct distances calculated. Shortest path reconstructed and displayed. Handles disconnected
graphs.
EXTENSION
TEACHER NOTES
This is a genuinely challenging task best reserved for A-Level students or exceptionally strong
GCSE students. Work through a small worked example on the board before students attempt to
code it.
[Link] · 55 / 87
Challenge 68 Tower of Hanoi
PROBLEM
Write a recursive function to solve the Tower of Hanoi puzzle for n discs. Display each move.
EXAMPLE
n=3:
Move disc 1 from A to C
Move disc 2 from A to B
Move disc 1 from C to B
...
7 moves total.
HINTS
Base case: move 1 disc directly. Recursive case: move n-1 discs to spare, move largest, move
n-1 back.
MARK SCHEME
Correct recursive implementation. All moves displayed correctly. Total moves = 2^n - 1.
EXTENSION
Count and display the total number of moves alongside the solution.
TEACHER NOTES
One of the classic recursion tasks. Students find it hard to write but satisfying when it works.
Start with n=2 and trace through on the board - the pattern becomes clear and the code almost
writes itself.
[Link] · 56 / 87
Challenge 69 Maze Solver
PROBLEM
Given a 2D grid maze (0=open, 1=wall), write a recursive function to find a path from a
start position to an end position.
EXAMPLE
HINTS
Try moving in each direction recursively. Mark cells as visited to avoid loops. Backtrack if stuck.
MARK SCHEME
Correct recursive backtracking. Path found if one exists. Returns no solution when none exists.
EXTENSION
Display the solved path marked on the grid with a special character.
TEACHER NOTES
PROBLEM
Implement the Vigenere cipher. Ask for a message and a keyword. Encrypt and display the
result.
EXAMPLE
Message: hello
Keyword: key
Encrypted: rijvs
HINTS
Each letter is shifted by the corresponding letter in the repeating keyword. Use ord() and chr().
MARK SCHEME
Correct encryption for all lowercase letters. Keyword repeats correctly. Non-letter characters
unchanged.
EXTENSION
Add decryption. Demonstrate how frequency analysis can help crack it.
TEACHER NOTES
Best done after challenge 29 (Caesar cipher). The key repeating correctly is the hardest part -
students often forget to use modulo on the key index.
[Link] · 57 / 87
Challenge 71 API Simulation
PROBLEM
Simulate a simple REST API using a dictionary. Write functions to handle GET (retrieve by
ID), POST (add new record), PUT (update), and DELETE.
EXAMPLE
HINTS
Store records in a dictionary keyed by ID. Each function receives an ID and optional data.
MARK SCHEME
All four operations work correctly. Correct error handling for missing records.
EXTENSION
Simulate HTTP status codes (200, 201, 404, 400) in return values.
TEACHER NOTES
Links well with theory on client-server architecture and HTTP methods. Students find it useful to
see the parallel between the function names and real HTTP verbs.
[Link] · 58 / 87
Challenge 72 Inventory System
PROBLEM
Build an inventory system using a dictionary. Each item has a name, quantity, and price.
Allow the user to add items, update stock, sell items (reducing quantity), and display low-
stock alerts (below 5 units).
EXAMPLE
HINTS
Use a dictionary keyed by item name. Each value is another dictionary with quantity and price.
MARK SCHEME
All operations work. Selling validates sufficient stock. Low-stock alert identifies all items below
threshold.
EXTENSION
Save and load inventory from a CSV file. Display total inventory value.
TEACHER NOTES
A good task for introducing nested dictionaries. Students who have only used flat dictionaries
may need a brief worked example showing how to access inner values.
[Link] · 59 / 87
Challenge 73 String Compression
PROBLEM
EXAMPLE
HINTS
MARK SCHEME
Correct compression. Single characters represented without a count (or as 1x). Handles empty
string.
EXTENSION
TEACHER NOTES
Links well with theory on compression. The edge case of a single-character run (should it print
'1a' or just 'a'?) is worth discussing as a design decision before students start.
[Link] · 60 / 87
Challenge 74 Full Number Base Converter
PROBLEM
Build a full converter between binary, decimal, octal, and hexadecimal in both directions,
without using Python's built-in conversion functions.
EXAMPLE
HINTS
For decimal to other: use repeated division. For other to decimal: multiply each digit by its
positional value.
MARK SCHEME
All conversion directions correct. User selects source and target base. Correct for any valid input.
EXTENSION
Add input validation for each base (e.g. binary input only contains 0 and 1).
TEACHER NOTES
A thorough task that tests understanding of number bases, not just the ability to call a function.
Best done after challenge 40 so students have already implemented one direction.
[Link] · 61 / 87
Challenge 75 FCFS Scheduler
PROBLEM
Given a list of tasks with arrival times and durations, implement a First Come First Served
(FCFS) scheduler. Display the processing order and average waiting time.
EXAMPLE
HINTS
Process tasks in arrival order. Track current time. Waiting time = start time - arrival time.
MARK SCHEME
Tasks processed in arrival order. Correct waiting times. Average calculated and displayed.
EXTENSION
Implement Shortest Job First (SJF) and compare average waiting times with FCFS.
TEACHER NOTES
Links directly with the operating systems topic in GCSE and A-Level specifications. Students
enjoy seeing the concrete numbers that explain why SJF is theoretically superior.
[Link] · 62 / 87
Challenge 76 Phone Number Formatter
PROBLEM
Write a function that takes a UK phone number string in any format (with or without spaces,
hyphens, or +44 prefix) and returns it in standard format: 07XXX XXXXXX.
EXAMPLE
HINTS
Strip all non-digit characters first. Handle +44 prefix by replacing with 0.
MARK SCHEME
Strips non-digit characters. Handles +44 prefix. Validates length. Returns standardised format.
EXTENSION
TEACHER NOTES
A practical real-world task. Students appreciate that this kind of string normalisation is common
in professional software. The various possible input formats make it a good test of systematic
thinking.
[Link] · 63 / 87
Challenge 77 Text Adventure Engine
PROBLEM
EXAMPLE
HINTS
Store room data in a dictionary. Each room has a description, exits (dict), and items (list).
MARK SCHEME
Room data stored as dictionary or class. Movement validated. Items tracked. Win condition
implemented.
EXTENSION
TEACHER NOTES
Students enjoy the creative aspect of designing their own rooms. Set a clear minimum (5 rooms,
movement working, at least one item) so they do not spend the entire lesson on story design.
[Link] · 64 / 87
Challenge 78 Sentiment Analyser
PROBLEM
Given lists of positive and negative words, analyse a user-entered sentence and classify it
as positive, negative, or neutral based on word counts.
EXAMPLE
HINTS
Convert to lowercase and split. Count how many words appear in each list.
MARK SCHEME
Correct word matching (case-insensitive). Correct classification. Score displayed alongside result.
EXTENSION
Load word lists from a file. Allow the user to add new words.
TEACHER NOTES
Accessible and engaging, especially linked to discussions about AI and natural language
processing. Students can test it with their own sentences and enjoy (or question) the results.
PROBLEM
Given a list of lessons (room, day, period), write a function that detects any room that is
double-booked (same room, day, and period).
EXAMPLE
HINTS
Use a dictionary keyed by (room, day, period) tuple. Check if the key already exists before
adding.
MARK SCHEME
All clashes correctly detected. Each clash reported with details. No false positives.
EXTENSION
Also detect teacher clashes (same teacher, same day, same period).
TEACHER NOTES
Introduces tuples as dictionary keys, which is a useful technique. Students who initially use three
separate nested dictionaries can be guided toward the tuple key approach as a cleaner solution.
[Link] · 65 / 87
Challenge 80 Pattern Matcher
PROBLEM
Write a simple pattern matching function that supports * (matches any sequence of
characters) and ? (matches any single character).
EXAMPLE
HINTS
Use recursion. Handle base cases: both empty = True, pattern empty but string not = False.
MARK SCHEME
Correct matching for ? (single character). Correct matching for * (any sequence). Handles edge
cases.
EXTENSION
TEACHER NOTES
A challenging task that requires careful recursive thinking. Walk through the base cases on the
board before students attempt it. Students who solve this have demonstrated a strong grasp of
recursion.
[Link] · 66 / 87
Stretch Challenges
Multi-part problems combining multiple skills. A-Level standard. Maps to NEA complexity
requirements.
PROBLEM
A library stores books (title, author, ISBN, available: True/False). Write a program that: adds
new books, searches by author or title, borrows a book (marks unavailable), returns a book,
and lists all available books.
EXAMPLE
borrow('978-0-06-112008-4')
'To Kill a Mockingbird' is now on loan.
search_author('Harper Lee')
To Kill a Mockingbird - On loan
HINTS
Use a list of dictionaries. Each dictionary is one book. Search returns all matches.
MARK SCHEME
All five functions implemented. Borrow validates availability. Search returns all matches
including unavailable books.
EXTENSION
Add a borrower name to borrowed books. Show who has each book currently.
TEACHER NOTES
A good first multi-function project. Students often implement each function independently
without testing them together - encourage them to run a full sequence of operations (add,
borrow, search, return) before submitting.
[Link] · 67 / 87
Challenge 82 Gradebook with File Persistence
PROBLEM
Build a gradebook that stores students and marks for up to 5 subjects, calculates each
student's average, saves to CSV on exit, loads from CSV on startup, and reports the top
student per subject.
EXAMPLE
HINTS
Use a list of dictionaries. Write CSV with a header row. Load using split(',').
MARK SCHEME
File I/O with correct CSV format. Correct averages. Top per subject identified. Handles missing
file on first run.
EXTENSION
TEACHER NOTES
This task requires students to plan a data structure before coding. Ask them to sketch the CSV
layout on paper first - students who skip this step tend to write file I/O that does not round-trip
correctly.
[Link] · 68 / 87
Challenge 83 Train Timetable
PROBLEM
Store a train timetable (departure station, arrival station, departure time, arrival time, price)
in a list of dictionaries. Write functions to: search by departure and arrival station, find the
cheapest route, find the fastest route, and display all trains after a given time.
EXAMPLE
search('London', 'Brighton')
Cheapest: 08:15 - 11.50
Fastest: 10:30 - 55 mins
HINTS
Store times as strings in HH:MM format or as integers (minutes since midnight) for easy
comparison.
MARK SCHEME
All four queries work correctly. Handles no results. Data stored as appropriate structure.
EXTENSION
TEACHER NOTES
The time comparison is the trickiest part. Discuss with students whether to store times as strings
or integers before they start - it affects every function they write afterwards.
[Link] · 69 / 87
Challenge 84 Password Manager
PROBLEM
Build a password manager that stores website, username, and password entries, encrypts
passwords using the Caesar cipher before storing, decrypts on retrieval, saves to a file, and
searches by website.
EXAMPLE
HINTS
Encrypt the password field only. Use a fixed shift stored in the program.
MARK SCHEME
All operations work. Encryption/decryption correct. File I/O persists data between runs.
EXTENSION
TEACHER NOTES
A good motivating task for discussing encryption in a real context. Acknowledge with students
that Caesar cipher is not real security - the task is about building the system structure, not
producing a secure product.
[Link] · 70 / 87
Challenge 85 Noughts and Crosses
PROBLEM
Implement a two-player Noughts and Crosses game. Display the board after each move.
Detect wins, draws, and invalid moves.
EXAMPLE
X | O | X
---|---|---
O | X |
---|---|---
| | O
X wins!
HINTS
Use a list of 9 elements for the board. Check all 8 win conditions (3 rows, 3 columns, 2
diagonals).
MARK SCHEME
Board displayed correctly after each move. All wins detected. Draw detected. Invalid moves
rejected.
EXTENSION
Add a computer player that makes random moves. Then try to make it play optimally.
TEACHER NOTES
Students are often familiar with the game, which helps. The win detection logic requires checking
8 combinations - encourage students to write this as a separate function rather than embedding
it in the main game loop.
[Link] · 71 / 87
Challenge 86 Hospital Priority Queue
PROBLEM
Patients have a name and priority level (1=urgent, 2=standard, 3=routine). Implement a
priority queue to process them in priority order, with equal-priority patients processed in
arrival order.
EXAMPLE
HINTS
MARK SCHEME
Correct priority ordering. FIFO within same priority. Dequeue processes in correct order.
EXTENSION
TEACHER NOTES
Links well with the queues theory topic and can generate a good discussion about how hospitals
or emergency services actually manage queues. The stable sort behaviour (preserving arrival
order within a priority level) is the key concept.
[Link] · 72 / 87
Challenge 87 Spell Checker
PROBLEM
Load a dictionary of correctly spelled words from a file. For each word in a user-entered
sentence, flag any word not in the dictionary and suggest the three closest matches.
EXAMPLE
HINTS
Edit distance: count insertions, deletions, and substitutions needed to transform one word to
another.
MARK SCHEME
Correctly flags unknown words. Three suggestions produced for each. Case-insensitive matching.
EXTENSION
Implement the full Levenshtein distance algorithm for more accurate suggestions.
TEACHER NOTES
Provide a word list file for students to load. The edit distance algorithm is the intellectual core of
this task - give stronger students time to discover it and weaker students a worked example to
implement.
[Link] · 73 / 87
Challenge 88 Bank Transaction Processor
PROBLEM
Read a CSV file of bank transactions (date, description, amount). Categorise each
transaction based on keywords in the description. Display total spending per category and
flag transactions above 100.
EXAMPLE
Food: 234.50
Entertainment: 45.00
Large transactions flagged:
12/03 Netflix Premium 149.99
HINTS
Use a dictionary of categories with keyword lists. Check if any keyword appears in the
description.
MARK SCHEME
Correct file read. Correct categorisation. Totals correct. Transactions above 100 flagged.
EXTENSION
TEACHER NOTES
Provide a sample transactions CSV file. Students often hard-code category keywords directly in
the comparison logic - encourage them to define keyword lists as a data structure they could
easily update.
[Link] · 74 / 87
Challenge 89 Cryptarithmetic Solver
PROBLEM
Solve the puzzle SEND + MORE = MONEY by assigning a unique digit (0-9) to each letter.
EXAMPLE
HINTS
Use [Link] to try all digit assignments. S and M cannot be 0 (leading digits).
MARK SCHEME
Correct solution found. Leading digit constraint applied. Solution displayed clearly.
EXTENSION
TEACHER NOTES
A good introduction to brute-force search. The program may take a few seconds to run - this is a
natural lead-in to discussing constraint propagation and why smarter search algorithms exist.
[Link] · 75 / 87
Challenge 90 Recursive Directory Tree
PROBLEM
Simulate a file system as nested dictionaries. Write a recursive function to display the full
directory tree with indentation showing depth.
EXAMPLE
root/
documents/
[Link]
[Link]
images/
[Link]
HINTS
A directory is a dict; a file is a string. Recurse when you encounter a dict value.
MARK SCHEME
Correct recursive traversal. Indentation reflects depth accurately. Files and folders distinguished.
EXTENSION
TEACHER NOTES
A satisfying recursion task with a very visual output. The key insight is distinguishing between
dictionary values (folders) and string values (files) - walk through this distinction before students
start.
[Link] · 76 / 87
Challenge 91 Compression Analysis
PROBLEM
EXAMPLE
HINTS
MARK SCHEME
Both algorithms correctly implemented. Compression ratio calculated accurately. Bar chart
proportional and labelled.
EXTENSION
Test on a paragraph of real text from a file. Which algorithm performs better on natural
language?
TEACHER NOTES
Links directly with theory on compression. Students are often surprised that RLE performs poorly
on natural language - this creates a useful discussion about why different compression
algorithms suit different data types.
[Link] · 77 / 87
Challenge 92 Supermarket Queue Simulation
PROBLEM
Simulate a supermarket checkout queue. Customers arrive at random intervals. Each takes
a random service time (1-5 mins). Run for 60 minutes. Display average waiting time and
peak queue length.
EXAMPLE
Simulation complete.
Customers served: 23
Average wait: 2.4 minutes
Peak queue length: 7
HINTS
Use a queue structure. Advance time in one-minute increments. Track when each customer
starts and finishes being served.
MARK SCHEME
Simulation runs for exactly 60 minutes. Randomised arrivals and service. Both statistics
calculated correctly.
EXTENSION
Add a second checkout that opens when the queue exceeds 5 people. Compare wait times.
TEACHER NOTES
[Link] · 78 / 87
Challenge 93 Polynomial Calculator
PROBLEM
EXAMPLE
HINTS
Derivative: multiply each coefficient by its power and reduce all powers by 1. Multiplication: use
a result list of length len(a)+len(b)-1.
MARK SCHEME
All four operations produce correct results. Derivative follows the power rule. Edge cases
handled.
EXTENSION
TEACHER NOTES
Most accessible to students with some Maths A-Level background. The list representation of
polynomials is clever and worth spending time on before students attempt the operations.
[Link] · 79 / 87
Challenge 94 Social Network
PROBLEM
Build a social network as an undirected graph using a dictionary of sets. Implement: add
user, add friendship, suggest friends (friends-of-friends not already connected), find
shortest connection path, and identify the most connected user.
EXAMPLE
HINTS
Use a dictionary of sets. Friend suggestions: find all friends-of-friends and remove existing
friends.
MARK SCHEME
Graph correctly maintained as bidirectional. Friend suggestions correct. BFS for shortest path.
Most connected user identified.
EXTENSION
Detect cliques - groups of three or more users who are all friends with each other.
TEACHER NOTES
One of the more open-ended tasks in this set. Students who implement BFS for the shortest path
are doing A-Level standard work. The friend suggestion algorithm alone is achievable for strong
GCSE students.
[Link] · 80 / 87
Challenge 95 Text RPG with Save/Load
PROBLEM
Build a role-playing game using classes. Player has health, attack, defence, and level.
Include at least three enemies. Implement turn-based combat, experience points, level-up
logic, and save/load game state to a file.
EXAMPLE
HINTS
Use Player and Enemy classes. Damage formula: [Link] - [Link] (minimum
1).
MARK SCHEME
Classes defined correctly. Combat system works. Level-up triggers at correct XP threshold. Save/
load preserves all player attributes.
EXTENSION
TEACHER NOTES
Students enjoy this task but often spend too long on content (enemies, story) rather than
structure (classes, save/load). Set clear time checkpoints: class design first, then combat, then
persistence.
[Link] · 81 / 87
Challenge 96 Web Server Log Analyser
PROBLEM
Parse a web server access log file. Display: total requests, top 5 most frequent IPs, top 5
most requested pages, count of each HTTP status code, and requests per hour.
EXAMPLE
HINTS
Split each log line by spaces to extract IP, request, and status code. Use dictionaries for
counting.
MARK SCHEME
Correct parsing for all five statistics. Handles malformed lines without crashing. Top 5 lists sorted
correctly.
EXTENSION
Flag any IP making more than 100 requests as a potential bot. Write a summary to a new file.
TEACHER NOTES
Provide a sample log file in standard Apache or Nginx format. Students learn a great deal about
real-world data from working with actual log formats rather than clean toy data.
[Link] · 82 / 87
Challenge 97 Constraint-Based Timetabler
PROBLEM
Given teachers (each assigned one subject) and rooms, generate a one-day timetable
across 6 periods. Constraints: no teacher double-booked; no room double-booked. Display
the timetable as a grid.
EXAMPLE
HINTS
Use a dictionary keyed by (period, room). Check constraints before each assignment.
MARK SCHEME
No constraint violations in output. All teachers scheduled. Grid display clear and readable.
EXTENSION
Use backtracking to find a valid schedule when greedy assignment produces a conflict.
TEACHER NOTES
Links well with the operating systems topic on scheduling. Students who reach the backtracking
extension are working at a level well above GCSE and this is worth recognising.
[Link] · 83 / 87
Challenge 98 Multi-File OOP School System
PROBLEM
Design a school management system across four files: [Link] (Student, Teacher,
ClassGroup classes), [Link] (save/load from CSV), [Link] (menu-driven UI), and
[Link] (entry point).
EXAMPLE
File structure:
[Link] -> class definitions
[Link] -> file I/O
[Link] -> menus and display
[Link] -> initialises and launches
HINTS
Import between files using standard imports. Avoid circular imports by keeping [Link] free of
other imports.
MARK SCHEME
Correct modular structure. Classes have __init__ and meaningful methods. File I/O persists
between runs. Interface imports cleanly from other modules.
EXTENSION
Add comprehensive input validation. Add a statistics function showing average class sizes.
TEACHER NOTES
This task mirrors the kind of modular design expected in A-Level NEA projects. Discuss the
separation of concerns principle before students start - why models, database, and interface
should be kept apart.
[Link] · 84 / 87
Challenge 99 k-Nearest Neighbours
PROBLEM
Implement the k-NN classification algorithm from scratch (no sklearn). Use the Iris dataset
as a CSV. Split into training and test sets. Classify each test point and report overall
accuracy.
EXAMPLE
k=3
Test set accuracy: 96.7%
Predicted: setosa, Actual: setosa
HINTS
Euclidean distance: square root of the sum of squared differences between features. Take
majority vote from k nearest.
MARK SCHEME
Correct Euclidean distance. Correct k nearest identified. Majority vote produces prediction.
Accuracy calculated over full test set.
EXTENSION
Test with k = 1, 3, 5, 7, 9. Display accuracy for each value and identify the best k.
TEACHER NOTES
Works well alongside an introduction to machine learning concepts. Provide the Iris dataset as a
CSV file. Students who implement this successfully have a strong foundation for understanding
supervised learning.
[Link] · 85 / 87
Challenge 100 Project Scoping Exercise
PROBLEM
This challenge has no code to write. Choose a real problem to solve with Python and
produce: (1) a problem statement, (2) a named stakeholder and their requirements, (3) six
measurable success criteria, (4) a list of Python techniques required, (5) pseudocode for the
most complex part, (6) a risk assessment with two risks and mitigations.
EXAMPLE
This is a planning and analysis exercise that mirrors the A-Level NEA Analysis and
Design sections.
HINTS
Every success criterion must be testable with a clear pass/fail outcome. Avoid vague objectives
like 'the system should be easy to use'.
MARK SCHEME
Problem is specific and real. Stakeholder is genuine (not invented). All six criteria are
measurable. Techniques are appropriate. Algorithm is detailed enough to code from. Risks are
plausible with realistic mitigations.
EXTENSION
Build it.
TEACHER NOTES
This task is best used as a transition exercise before starting an NEA or coursework project.
Students who struggle to identify a real problem benefit from a short class discussion about
problems they encounter in daily life.
[Link] · 86 / 87
CodeBash
The interactive coding platform for UK schools
[Link]
[Link] · 87 / 87