Level:
Correct: 0
Incorrect: 0
Marks: 0/0
Exam Practice
Course:
Topics:
AQA GCSE Computer Science (Paper 1) Smart practice A mixed round aimed at your weak spots
Unit 1
3.1 Fundamentals of algorithms
Unit 2
3.2 Programming
Data types
Data types
Arithmetic operations in a programming language
Arithmetic operations, DIV and MOD
Relational operations in a programming language
Relational operations
Boolean operations in a programming language
Boolean operations in conditions
Data structures
Arrays and records
Input/output
Input and output
String handling operations in a programming language
String handling
Random number generation in a programming language
Random number generation
Structured programming and subroutines (procedures and functions)
Subroutines and structured programming
Avg
score:
–
Topics
done:
0/15

Validation, authentication, testing and errors

Practise 35 exam-style questions on Validation, authentication, testing and errors for AQA GCSE Computer Science (Paper 1). Write your answer as you would in the exam and get it marked in seconds against the mark scheme, point by point, with the Study Helper on hand if you get stuck.

  • 35 questions
  • 1–8 marks each
  • Instant marking
  • No sign-up needed
20 questions, marked as you go

Sample questions with model answers

Here are 4 of the questions in this topic, each with a model answer, an explanation of why it earns the marks and the mark scheme an examiner would use.

Question 1

2 marks

An online game's login routine locks a player's account after three incorrect passwords have been entered.

Explain why the routine limits the number of attempts.

Model answer

Without a limit, someone who does not know the password could keep trying different passwords until one works. Locking the account after three wrong attempts means they only get three guesses, which makes it very unlikely they can get into the player's account.

Explanation

An authentication routine with unlimited attempts lets an attacker keep guessing, possibly automatically. A small limit makes guessing impractical while still allowing a genuine user a couple of typing mistakes. 'It is more secure' needs a reason to earn credit.

Mark scheme
  1. 1 mark

    To stop someone who is not the player (an unauthorised person) trying password after password until they guess it

    2 marks for AO1 (understanding). 1 mark for the reason, 1 mark for the expansion. A. 'to prevent a brute-force attack'.

  2. 1 mark

    An expansion, e.g. with only three attempts the chance of guessing the correct password is very small, so the player's account (and data) is kept secure

    'It is more secure' on its own scores 0: the first mark needs the idea of someone trying many passwords.

Question 2

2 marks

A shop's product codes must be from 5 to 8 characters long. A programmer wants to test the length check with boundary test data.

Give the length, in characters, of each of the four strings the programmer should use, and say whether each string should be accepted or rejected.

Model answer

4 characters - rejected
5 characters - accepted
8 characters - accepted
9 characters - rejected

Explanation

For a length check, the boundaries are on the number of characters, so the boundary data is strings either side of each limit: 4 and 5 characters at the lower limit and 8 and 9 at the upper limit. The shortest and longest valid codes should be accepted and the ones just outside should be rejected. A code of 6 characters would be normal data.

Mark scheme
  1. 1 mark

    4 characters (rejected) and 5 characters (accepted)

    2 marks for AO3 (test). Both lengths with the correct outcome are needed for each mark. A. example strings of the right lengths.

  2. 1 mark

    8 characters (accepted) and 9 characters (rejected)

Question 3

3 marks

A garden centre's ordering program validates the number of plants in an order using the algorithm below.

invalid ← 0
REPEAT
  qty ← USERINPUT
  IF qty < 1 THEN
    OUTPUT 'Too low'
    invalid ← invalid + 1
  ELSE IF qty > 50 THEN
    OUTPUT 'Too high'
    invalid ← invalid + 1
  ENDIF
UNTIL qty ≥ 1 AND qty ≤ 50
OUTPUT invalid

State the output of the algorithm when the user enters 0, then 75, then 30. Write each line of output on a new line.

Model answer

Too low
Too high
2

Explanation

0 is below 1, so Too low is output and invalid becomes 1; 75 is above 50, so Too high is output and invalid becomes 2. 30 is in range, so neither message is output and the UNTIL condition is True, ending the loop. The final output is the number of invalid entries, 2, not the number of entries.

Mark scheme
  1. 1 mark

    Too low (first line)

    All marks AO2 (apply). 1 mark for each correct line. Maximum 2 marks if the lines are not in this order. I. Quotation marks.

  2. 1 mark

    Too high (second line)

  3. 1 mark

    2 (third line)

    R. 3 (30 is valid, so invalid is not increased for it).

Question 4

4 marks

The subroutine getLength should keep asking the user for some text until its length is from minLen to maxLen characters inclusive, and then pass the text back to the calling routine. Four parts have been replaced by the gaps [ A ], [ B ], [ C ] and [ D ].

SUBROUTINE getLength(minLen, maxLen)
  text ← USERINPUT
  WHILE LEN(text) < [ A ] OR LEN(text) > [ B ]
    OUTPUT 'Must be ' + INT_TO_STRING(minLen) + ' to ' + INT_TO_STRING(maxLen) + ' characters'
    text ← [ C ]
  ENDWHILE
  [ D ] text
ENDSUBROUTINE

nickname ← getLength(3, 12)
OUTPUT nickname

State the pseudo-code that should replace each of the gaps [ A ], [ B ], [ C ] and [ D ].

Model answer

A: minLen
B: maxLen
C: USERINPUT
D: RETURN

Explanation

The loop must use the parameters minLen and maxLen so that the same subroutine can validate any length range, which is the point of writing validation as a subroutine. The text is entered again inside the loop, and RETURN passes the valid text back, where it is stored in nickname. Writing 3 and 12 would only work for this one call.

Mark scheme
  1. 1 mark

    A: minLen

    All marks AO2 (apply). I. Case. R. 3 (the subroutine must work for any limits passed to it).

  2. 1 mark

    B: maxLen

    R. 12.

  3. 1 mark

    C: USERINPUT

  4. 1 mark

    D: RETURN

Ready to try the rest? Every answer you write is marked against the mark scheme, so you can see exactly where the marks are.

Study Helper Hints first, answers after you try

Stuck on this one? Ask for a hint and I’ll point you in the right direction, without giving the answer away. Once you’ve checked your answer, I’ll show you how the marks are awarded.