Skip to content

2.3.2 Testing Practice Questions

GCSE · Paper 2 · Computational thinking, algorithms and programming · 10 practice questions · 40 marks

Exam questions for 2.3.2 Testing

10 practice questions (40 marks) with mark schemes

Answer each question, reveal the mark scheme, then award yourself marks. Scores and answers are saved in this browser so you can see which topics need more work.

Practice questions

  1. Question 1Practice question · J277/02 style2 marks

    State two reasons why a programmer tests a program. [2]

    Show mark scheme

    Any two from: To find errors / bugs so they can be fixed (1) To check the program does what it was designed to do / meets the requirements (1) To check the program is robust / copes with unexpected data without crashing (1)

    Mark yourself: how many marks did you get?
    / 2
  2. Question 2Practice question · J277/02 style4 marks

    Compare iterative testing and final (terminal) testing. [4]

    Show mark scheme

    Iterative testing: Takes place during development / as each part of the program is written (1) Tests small parts such as one sub program, and errors are found early when they are easier to fix (1) Final testing: Takes place at the end, once the program is finished (1) Tests the whole program to check it works together and meets the requirements (1) Award the marks for a comparison only if both types are covered. A list about only one type earns a maximum of 2 marks.

    Mark yourself: how many marks did you get?
    / 4
  3. Question 3Practice question · J277/02 style4 marks

    Two short programs are shown. Each should print "Pass" for a score of 50 or more and "Fail" for a lower score. Program A

    01 if score >= 50 then
    02     print("Pass")
    03 else
    04     print("Fail")

    Program B

    01 if score > 50 then
    02     print("Pass")
    03 else
    04     print("Fail")
    05 endif

    (a) One program has a syntax error. State which one and explain what the error is. [2] (b) One program has a logic error. State which one and explain what the error is. [2]

    Show mark scheme

    (a) Program A (1). The endif is missing / the if statement is not closed, which breaks the rules of the language (1) (b) Program B (1). It uses > instead of >=, so a score of exactly 50 prints Fail when it should print Pass (1). The program runs, but the output is wrong.

    Mark yourself: how many marks did you get?
    / 4
  4. Question 4Practice question · J277/02 style4 marks

    A program asks for the age of a player. The age must be a whole number from 11 to 16 inclusive. Give one example of each type of test data for this program. (a) Normal [1] (b) Boundary [1] (c) Invalid [1] (d) Erroneous [1]

    Show mark scheme

    (a) Any whole number from 12 to 15 (1) (b) 11 or 16 (1) (c) Any whole number below 11 or above 16, such as 10, 17 or 40 (1) (d) Data that is not a whole number, such as "twelve" or "abc" (1) Do not award (c) for text, and do not award (d) for a number.

    Mark yourself: how many marks did you get?
    / 4
  5. Question 5Practice question · J277/02 style5 marks

    A fairground ride program asks for a rider's height in whole centimetres. A rider can go on the ride if the height is from 120 to 200 inclusive. An incomplete test plan is shown.

    TestTest dataType of dataExpected result
    1150(a)Accepted
    2(b)BoundaryAccepted
    3119(c)Rejected
    4tall(d)(e)

    Complete the gaps (a) to (e). [5]

    Show mark scheme

    (a) Normal (1) (b) 120 or 200 (1) (c) Invalid (1) (d) Erroneous (1) (e) Rejected / an error message is displayed (1)

    Mark yourself: how many marks did you get?
    / 5
  6. Question 6Practice question · J277/02 style6 marks

    A game asks for the number of players. It must be a whole number from 2 to 4 inclusive. Create a test plan with six tests. For each test, give the test data, the type of test data, and the expected result. Include all four types of test data. [6]

    Show mark scheme

    Award 1 mark for each row, up to 6 marks, where the data suits the type given and the expected result is correct. Award a maximum of 5 marks if any of the four types is missing.

    Test dataType of dataExpected result
    3NormalAccepted
    2BoundaryAccepted
    4BoundaryAccepted
    1InvalidRejected / error message
    5InvalidRejected / error message
    threeErroneousRejected / error message

    Other correct choices are acceptable, for example 0, 6 or 20 for invalid and abc or a symbol for erroneous.

    Mark yourself: how many marks did you get?
    / 6
  7. Question 7Practice question · J277/02 style6 marks

    This program should read five test scores, work out the average, and print "Pass" if the average is 50 or more.

    01 total = 0
    02 for i = 1 to 4
    03     score = int(input("Enter score"))
    04     total = total + score
    05 nxt i
    06 average = total / 5
    07 print("Average: " + str(average))
    08 if average > 50 then
    09     print("Pass")
    10 else
    11     print("Fail")
    12 endif

    The program has three errors. For each one, give the line number, state whether it is a syntax error or a logic error, and write the corrected line. [6]

    Show mark scheme

    Line 02: logic error (1). Correction: for i = 1 to 5 (1). Only four scores are read, but the total is divided by 5. Line 05: syntax error (1). Correction: next i (1) Line 08: logic error (1). Correction: if average >= 50 then (1). An average of exactly 50 must print Pass. Award the first mark of each pair for the correct line and error type together. Do not award the correction mark without the correct line. Check: with the scores 40, 50, 60, 50 and 50 the total is 250, the average is 50, and the corrected program prints Pass.

    Mark yourself: how many marks did you get?
    / 6
  8. Question 8Practice question · J277/02 style3 marks

    A programmer fixes an error that was found during testing. (a) Explain why the programmer should run the earlier tests again after the fix. [2] (b) Give one other way a programmer might refine an algorithm. [1]

    Show mark scheme

    (a) To check that the error has now been fixed (1) To make sure the fix has not caused a new error in something that used to work (1) (b) Any one from: make it more robust by adding validation / make it easier to read with better names, indentation or comments / make it quicker to run (1)

    Mark yourself: how many marks did you get?
    / 3
  9. Question 9Practice question · J277/02 style4 marks

    A program should accept a whole number from 1 to 10 inclusive.

    01 number = int(input("Enter a number from 1 to 10"))
    02 if number > 1 AND number < 10 then
    03     print("Accepted")
    04 else
    05     print("Rejected")
    06 endif

    (a) State which type of test data would show that the program is wrong, and give one example. [2] (b) State what type of error is in the program. [1] (c) Write a corrected version of line 02. [1]

    Show mark scheme

    (a) Boundary data (1), for example 1 or 10 (1). Both are valid but the program prints Rejected. (b) Logic error (1) (c) if number >= 1 AND number <= 10 then (1)

    Mark yourself: how many marks did you get?
    / 4
  10. Question 10Practice question · J277/02 style2 marks

    Explain why a test plan for a range check should include boundary data. [2]

    Show mark scheme

    Mistakes with comparison operators such as < instead of <=, or > instead of >=, show up at the edges of the range (1) Testing the lowest and highest allowed values checks that they are accepted correctly (1)

    Mark yourself: how many marks did you get?
    / 2
General Exam Advice
  • •Practice answering questions under timed conditions
  • •Check your answers against the mark scheme carefully
  • •Focus on understanding the marking points, not just memorising answers
  • •Come back to the questions you dropped marks on a few days later