AQA GCSE Computer Science June 2022 Paper 1, Question 7: the email match program
AQA 8525 June 2022 Paper 1, Question 7: write a Python program that asks for an email address twice and says whether they match. A model answer, the five marks explained, and the program to run.
Question 7 of the AQA GCSE Computer Science June 2022 Paper 1 (8525/1B, the Python paper) is the first "write a program" question on the paper. It is worth 5 marks and needs seven lines. You have filled in forms that do exactly this.
We do not copy the exam paper here. Open it beside this page: AQA June 2022 Paper 1B question paper (PDF). When you have finished, check the mark scheme too.
The question in short
The program must:
- get the user to enter an email address;
- get them to enter it a second time;
- output
Matchand the email address if the two are the same; - output
Do not matchif they are different.
A model answer
email1 = input("Enter your email address: ")
email2 = input("Enter it again: ")
if email1 == email2:
print("Match")
print(email1)
else:
print("Do not match")
Where the five marks are
Two marks are for design, given even if the syntax is wrong:
- two variables with meaningful names, one for each email address;
- using selection.
Three marks are for a program that works:
- both inputs stored correctly;
- a correct comparison of the two:
==, or!=with the branches swapped; MatchandDo not matchin separate branches, and the email address output when they match.
Any error in the code caps you at 4.
Where the marks are lost
- Forgetting to output the email address. The third bullet of the question asks for two things: the message and the address. Leave the address out and the last mark goes.
=in theif. One equals sign assigns. Two compare.if email1 = email2:is a syntax error.- Names like
aandb. A design mark is for meaningful variable names.email1andemail2are fine. - One variable used twice.
email = input()twice over loses the first address. You need two variables to have two things to compare.
Run it
The robot's light is green for a match and red for no match.
The program
from bugbot import *
connect()
email1 = input("Enter your email address: ")
email2 = input("Enter it again: ")
if email1 == email2:
led("green")
print("Match")
print(email1)
else:
led("red")
print("Do not match")
Now change it
Ada@school.uk and ada@school.uk do not match, but they are the same email address. Make the comparison ignore capital letters. Then make the program keep asking until the two do match.
Answer
Compare email1.lower() with email2.lower(). To keep asking, put both inputs inside a while loop that repeats while the two are different.Questions
What is the answer to AQA GCSE Computer Science 2022 Paper 1 Question 7?
Store two inputs in two variables, compare them with ==, print Match and the email address if they are equal, and print Do not match in the else branch.
How do you compare two strings in Python?
Use == to test whether they are the same and != to test whether they are different. The comparison is case sensitive, so "Ada" and "ada" are not equal.
Why do AQA mark schemes give marks for meaningful variable names?
Because readable code is part of good program design. A name should say what the variable holds, such as email1 or total, and not just be a letter.
More from this paper
- Question 8: A bonus payment from items sold and years employed 7 marks
- Question 13.1: Keep asking until a number is between 1 and 100 4 marks
- Question 13.2: Find a run of five in a sorted array of 100 cards 6 marks
- Question 14.2: Write a subroutine that counts the asterisks on a bingo ticket 8 marks
Every AQA 8525 question we have worked
Learn it step by step
- F1.7 Input from the user Programming basics
- F2.2 Selection: if Decisions and loops
- F13.4 Programming questions Exam preparation
This is our own explanation of a published exam question. It is not written or endorsed by AQA, and the question paper and mark scheme remain AQA's copyright. Read them on AQA's site with the links on this page.