For IndividualsFor Educators
ExpertMinds LogoExpertMinds
ExpertMinds

Ace your certifications with Practice Exams and AI assistance.

  • Browse Exams
  • For Educators
  • Blog
  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • Support
  • AWS SAA Exam Prep
  • PMI PMP Exam Prep
  • CPA Exam Prep
  • GCP PCA Exam Prep

© 2026 TinyHive Labs. Company number 16262776.

    PracticeAQA GCSEAQA GCSE Computer Science Paper 1 PythonQuestion 06
    Medium4 marksStructured
    Fundamentals of algorithmsGeneralalgorithmspseudo-codeauthentication

    AQA GCSE · Question 06 · Fundamentals of algorithms

    Figure 5 shows an algorithm for a simple authentication routine. Parts of the algorithm are missing and have been replaced with the labels L1 to L4.

    Figure 5
    login ← False
    REPEAT
    username ← ""
    WHILE username = ""
    OUTPUT 'Enter username: '
    username ← L1
    ENDWHILE
    password ← ""
    WHILE password = ""
    OUTPUT 'Enter password: '
    password ← USERINPUT
    ENDWHILE
    storedPassword ← getPassword(L2)
    IF storedPassword = L3 THEN
    OUTPUT L4
    ELSE
    IF password = storedPassword THEN
    login ← True
    ELSE
    OUTPUT 'Try again.'
    ENDIF
    ENDIF
    UNTIL login = True
    OUTPUT 'You are now logged in.'
    State the items from Figure 6 that should be written in place of the labels in the algorithm in Figure 5. You will not need to use all the items.

    Figure 6

    -1OUTPUT0
    usernameTrueSUBROUTINE
    1User not found""
    USERINPUTpasswordWrong password

    How to approach this question

    Analyse each label in the context of the pseudo-code. 1. **L1:** `username ← L1`. This line is inside a loop that prompts the user to "Enter username:". The purpose is to get input from the user and store it in the `username` variable. The correct item from Figure 6 is `USERINPUT`. 2. **L2:** `storedPassword ← getPassword(L2)`. The `getPassword` subroutine needs to know which user's password to look up. The username has just been entered by the user and is stored in the `username` variable. Therefore, L2 should be `username`. 3. **L3:** `IF storedPassword = L3 THEN`. This `IF` statement handles the case where the user does not exist. The problem description states that `getPassword` returns an empty string if the username does not exist. Therefore, the code needs to check if `storedPassword` is an empty string. The correct item is `""`. 4. **L4:** `OUTPUT L4`. This is the output shown when the username was not found (as determined by the `IF` statement for L3). The appropriate message is `User not found`.

    Full Answer

    This question tests understanding of a common authentication algorithm. - **L1:** The code prompts for a username and then needs to accept the user's typed response. The standard pseudo-code command for this is `USERINPUT`. - **L2:** The `getPassword` subroutine is called to retrieve the stored password for the user who is trying to log in. The program has just stored the entered username in the `username` variable, so this variable must be passed to the subroutine as an argument. - **L3:** The problem states that `getPassword` returns an empty string if the user is not found. The `IF` statement is checking for this specific case. Therefore, it must compare `storedPassword` to an empty string, which is represented as `""`. - **L4:** If the condition for L3 is met (the user was not found), an appropriate message should be displayed. From the options, `User not found` is the correct message.

    Common mistakes

    ✗ Mixing up the variables, e.g., putting `password` for L2.\n✗ Misunderstanding the purpose of the `IF` statement at L3, perhaps choosing `0` or `-1` instead of the empty string `""`.
    Question 05All questionsQuestion 07

    Practice the full AQA GCSE Computer Science Paper 1 Python

    31 questions · hints · full answers · grading

    Sign up freeTake the exam

    More questions from this exam

    Q01.1Figure 1 shows an algorithm, represented using pseudo-code, which assigns a different value to fo...EasyQ01.2The variable `x` is assigned a value using the statement: `x ← LEN(state)` Using Figure 1, what ...EasyQ01.3What is the result of concatenating the contents of the variables `city` and `landmark` in Figure 1?EasyQ01.5The subroutine `POSITION` finds the first position of a character in a string. For example, `POSI...EasyQ02.1Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-co...Easy
    View all 31 questions →