Community resourceWorksheet

1CP2-CT-5.6 Authentication with ID and password lookup

Part 6 of 7 · 1CP2-CT-5 · Merge sort, files and authentication

The authentication worksheet, matching a credential pair on the same record rather than anywhere in the file.

Students will:

  • keep validation and authentication distinct
  • explain why matching fields independently is insecure
  • implement a lookup that compares both fields of one record
  • describe the stages of authenticating against an accounts file
  • give three authentication tests with expected outcomes

Inside: 7 explanation cells, 3 multiple-choice questions, 1 Python task, 1 fill-in-the-blanks cell and 3 written answers. 20 marks, about 45 minutes.

Series: 1CP2-CT-5 · Merge sort, files and authentication, part 6 of 7.

Shared by Coding PathwayVerified teacher

  • 15 cells
  • About 45 minutes
  • CC BY-SA 4.0
  • Shared 17 Aug 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

Authentication with ID and password lookup

Authentication checks that a user is who they claim to be. Pearson requires programs that use an ID and password lookup. Both credentials must match the same stored record before access is granted.

1. Keep validation and authentication distinct

ID and password authentication lookupentered IDand passwordsame record:ID match AND password match?grant accessdeny accessyesno / endAuthentication verifies identity; validation only checks whether input follows rules.

Validation checks whether input follows rules, such as an ID being present. Authentication compares the claimed identity with stored credentials. A well-formed ID can still be unauthorised, so successful validation does not grant access.

Fill in the blanks3 marks
gap 1 checks input against rules. gap 2 verifies identity. Access is granted only when the ID gap 3 password match one stored record.
  • AND
  • Authentication
  • OR
  • Validation

2. Predict a lookup

accounts = [["s101", "fern"], ["s205", "orbit"]]
entered_id = "s101"
entered_password = "orbit"
authenticated = False
for account in accounts:
    if account[0] == entered_id and account[1] == entered_password:
        authenticated = True
print(authenticated)
Multiple choice1 mark

What is printed?

  • A`True`, because each credential appears somewhere
  • B`False`, because the credentials do not match the same record
  • C`s101`
  • D`orbit`
Written answer2 marks

Explain why checking whether the ID and password each appear anywhere in the file would be insecure.

Use the relationship between credentials and one account.

Students type their answer here.

3. Implement the lookup

Search the supplied accounts for the entered ID and password. Use a Boolean authenticated. Stop searching after a successful match and print exactly Access granted or Access denied.

Coding task5 marks
accounts = [["s101", "fern"], ["s205", "orbit"], ["s318", "river"]]
entered_id = "s205"
entered_password = "orbit"
authenticated = False
index = 0
# Complete the bounded authentication lookup.

4. Connect the lookup to a file

A CSV account file might contain one ID,password record per line. The program reads a line, strips and splits it, and compares both fields. In a real system, passwords should not be stored as readable plain text; this classroom representation exists to practise the required lookup algorithm, not to model production password storage.

Written answer4 marks

Describe the stages needed to authenticate credentials using an accounts.csv file.

Begin with opening the file and end with a decision and close.

Students type their answer here.

Multiple choice1 mark

An entered ID passes a presence check but is not in the accounts file. What should happen?

  • AAccess is granted because validation passed.
  • BAuthentication fails and access is denied.
  • CThe first account is selected.
  • DThe file is overwritten.

5. Test both sides of the decision

Authentication tests must include a correct pair, a correct ID with wrong password, an unknown ID, and credentials taken from different accounts. Expected outcomes matter: only the correct pair should grant access.

Written answer3 marks

Give three authentication tests with expected outcomes, including one valid and two invalid cases.

Use distinct failure reasons.

Students type their answer here.

Multiple choice1 mark

Which condition correctly authenticates the current record?

  • A`id_matches or password_matches`
  • B`id_matches and password_matches`
  • C`not id_matches`
  • D`id_matches` only

Route forward

You can combine input, file/record handling, search, selection and Boolean logic in an authentication lookup. The CT checkpoint now consolidates the Y10-5 programming sequence without assessing principles content.