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.

Past paper questionAQA 8525/1BJune 2022 Paper 15 marksWrite a program

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 Match and the email address if the two are the same;
  • output Do not match if 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;
  • Match and Do not match in 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 the if. One equals sign assigns. Two compare. if email1 = email2: is a syntax error.
  • Names like a and b. A design mark is for meaningful variable names. email1 and email2 are 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.

Type the same address twice for Match and the address. Make a typing mistake the second time for Do not 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")
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

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

Every AQA 8525 question we have worked

Learn it step by step

  1. F1.7 Input from the user Programming basics
  2. F2.2 Selection: if Decisions and loops
  3. F13.4 Programming questions Exam preparation
Open the lessons

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.