A2 Python Programming – Practice Worksheet
Lists • Functions • Procedures • Integration
Name: ______________________ Date: ____________ Score: ______ / 60
How to use this worksheet
Welcome! By this point you are comfortable with variables, loops and conditionals. This worksheet helps
you take the next step: combining those building blocks to manipulate lists, design your own functions
(which return a value) and procedures (which carry out an action but do not return anything).
The focus is on logic and data manipulation, not memorising algorithms. You will not be asked to write
any searching or sorting routines here – instead you will practise filtering, transforming, counting,
summarising and displaying data cleanly.
Write your answers in the boxes provided. Aim for code that is correct first, then tidy and readable. Use
sensible variable names and comment anything tricky. Take your time, and don't be afraid to plan on paper
before you type. You've got this!
Section A — Working with Lists
Q1. Filter into a new list [3 marks]
A list of integers called numbers is already defined. Write code that builds a new list called multiples
containing only the values that are exactly divisible by [NUMBER], then prints it.
Requirements:
• Use a loop to test each value – do not use a ready-made filtering shortcut.
• Leave the original numbers list unchanged.
Example:
numbers = [12, 7, 20, 15, 9, 30] (divisor = 5)
multiples = [20, 15, 30]
Write your Python code below:
A2 Python Programming – Lists, Functions & Procedures Page 1
Q2. Transform a list in place [4 marks]
A list temperatures stores values in degrees Celsius. Write code that converts every value to Fahrenheit
and updates the list in place (do not build a second list). The formula is F = C * 9 / 5 + 32. Print the
updated list afterwards.
Requirements:
• Modify the existing list by index, rather than creating a new one.
• Round each converted value to 1 decimal place.
Example:
Before: [0, 25, 37.0, 100]
After : [32.0, 77.0, 98.6, 212.0]
Write your Python code below:
Q3. Count values that meet a condition [3 marks]
A list of strings called words is provided. Write code that counts how many words are longer than
[NUMBER_OF_CHARACTERS] characters and prints that count.
Requirements:
• Use a counter variable that starts at zero and a loop.
• Print a clear message, e.g. Words over 4 letters: 2.
Example:
words = ["sky", "python", "code", "variable"] (threshold = 4)
Output: 2
Write your Python code below:
A2 Python Programming – Lists, Functions & Procedures Page 2
Q4. Parallel lists – names and scores [5 marks]
Two equal-length lists store class data: students holds names and scores holds the matching marks. Write
code that (a) prints each student's name next to their score, and (b) prints the name of the student with the
highest score.
Requirements:
• Use index-based looping so each name stays aligned with the correct score.
• You may assume both lists are the same length and that there is one clear top score.
Example:
students = ["Ayan", "Bilal", "Sara"]
scores = [72, 88, 81]
Top scorer: Bilal
Write your Python code below:
Section B — Functions (that return a value)
Q5. Define and call a function [2 marks]
Write a function rectangle_area(length, width) that returns the area of a rectangle. Then call it using
[SPECIFIC_DATA_EXAMPLE] and print the result.
Requirements:
• The function must use return – do not print inside it.
Write your Python code below:
A2 Python Programming – Lists, Functions & Procedures Page 3
Q6. Return different values with conditions [4 marks]
Write a function grade(mark) that returns a letter grade: A for 80 and above, B for 70–79, C for 60–69, and
the string "Fail" for anything below 60. Demonstrate the function by calling it with three different marks and
printing each result.
Requirements:
• All decisions happen inside the function; the calling code only prints.
Write your Python code below:
Q7. Return a Boolean (validation) [4 marks]
Write a function is_valid_password(password) that returns True only when the password is at least
[NUMBER] characters long and contains at least one digit. Otherwise it returns False.
Requirements:
• The function returns a Boolean – it must not print anything itself.
• Show the function working by testing one valid and one invalid password.
Example:
is_valid_password("hello1") -> True
is_valid_password("hello") -> False
Write your Python code below:
A2 Python Programming – Lists, Functions & Procedures Page 4
Q8. Return more than one value [5 marks]
Write a function min_and_max(values) that takes a list of numbers and returns both the smallest and the
largest value. Then call it and print both results.
Requirements:
• Work the smallest and largest out yourself with a loop.
• Do not use the built-in min() or max() functions.
• Return two values, e.g. return smallest, largest.
Example:
min_and_max([4, 9, 2, 7]) -> returns 2 and 9
Write your Python code below:
Section C — Procedures (that perform an action)
A procedure is a function that carries out a task – usually printing or changing data – but does not use a return
statement to hand a value back.
Q9. Procedure for formatted output [5 marks]
Write a procedure print_receipt(items, prices) that takes two parallel lists and prints a tidy receipt.
Each line shows an item name and its price, and the final line shows the total cost.
Requirements:
• The procedure must not return anything.
• Use the two lists together so each item lines up with its price.
• Aim for neat alignment in the printed output.
Example:
Pen ............ 1.50
Notebook ....... 3.20
Eraser ......... 0.80
TOTAL .......... 5.50
Write your Python code below:
A2 Python Programming – Lists, Functions & Procedures Page 5
Q10. Procedure that prints a pattern [3 marks]
Write a procedure print_star_rows(counts) that takes a list of integers. For each integer n in the list, it
prints one row containing n star characters.
Requirements:
• Use a loop to walk through the list, and produce each row of stars.
• The procedure does not return a value.
Example:
counts = [3, 1, 4]
***
*
****
Write your Python code below:
Q11. Procedure that changes a list [5 marks]
Write a procedure add_bonus(scores, bonus) that adds bonus to every element of the list scores,
changing the list itself. The procedure returns nothing. After calling it, print the list to show it has changed.
Requirements:
• Modify the list in place – no new list, no return.
• In one sentence under your code, explain why the original list is changed even though nothing was returned.
Example:
scores = [55, 60, 70] (bonus = 5)
After add_bonus(scores, 5): [60, 65, 75]
Write your code, then your one-sentence explanation:
Section D — Putting It Together
A2 Python Programming – Lists, Functions & Procedures Page 6
Q12. A function that summarises a list [4 marks]
Write a function average(values) that returns the mean (average) of a list of numbers. Then write code that
prints the average of [SPECIFIC_DATA_EXAMPLE].
Requirements:
• Calculate the total with a loop, then divide by how many items there are.
• If the list is empty, the function should return 0 (avoid dividing by zero).
Write your Python code below:
Q13. A function and a procedure working together [6 marks]
(a) Write a function passing_students(students, scores, pass_mark) that returns a new list of the
names of students whose score is at least pass_mark.
(b) Write a procedure display_names(names) that prints the heading "Students who passed:" and
then each name on its own line.
(c) Call the function, then pass its result straight into the procedure.
Requirements:
• The function returns data; the procedure handles all the printing.
• Keep the two jobs cleanly separated – this is good program design.
Example:
students = ["Ayan", "Bilal", "Sara"]
scores = [45, 88, 61] (pass_mark = 50)
Result -> ["Bilal", "Sara"]
Write your Python code below:
A2 Python Programming – Lists, Functions & Procedures Page 7
Q14. Working with a list of lists [5 marks]
A list called sales contains several inner lists, each holding the daily sales figures for one week. Write a
function weekly_totals(sales) that returns a new list containing the total of each inner list. Then print the
returned list.
Requirements:
• Use a loop inside a loop (a nested loop) to reach the inner values.
• The outer result list should have one total per inner list.
Example:
sales = [[120, 90, 75], [60, 80, 100]]
weekly_totals(sales) -> [285, 240]
Write your Python code below:
Q15. Challenge – a mini class-mark manager [7 marks]
Bring everything together. Using two parallel lists – names and marks with [NUMBER_OF_ITEMS] students –
build a small program that:
Requirements:
• uses a function average(marks) to find the class average;
• uses a function count_above(marks, value) to count how many marks are above a given value;
• uses a procedure print_report(names, marks) that lists each student with their mark, then prints the class
average and how many students scored above that average.
Plan first if it helps, then write your full program below:
A2 Python Programming – Lists, Functions & Procedures Page 8
Well done for working through this!
Notice how the same few ideas – looping over a list, returning a value, and carrying out an action – combine
to solve much bigger problems. That habit of breaking a task into small, reusable functions and
procedures is exactly how professional programmers work.
When you review your answers, ask yourself: Is each function doing just one clear job? Are my variable
names readable? Could someone else follow my logic? Keep practising, stay curious, and bring any
questions to your next session. Happy coding!
A2 Python Programming – Lists, Functions & Procedures Page 9