Skip to content

Course home

Testing

Testing

EasyMedium
123
Question 1

A local community library is writing an algorithm to record the genre of books donated by the public (for example, "Mystery").

variable.length returns the number of characters in variable.
variable.upper returns the characters in variable in upper case.

    valid = false

    while (valid == false)

        genreName = input("Enter the genre: ")

        if (genreName.length > 2) AND (genreName.length < 15)

            genreSaved = genreName.upper

            valid = true

            print("Genre accepted")

        else

            print("Invalid genre, try again")

        endif

    endwhile

The algorithm needs testing to make sure the decision block (if-else statement) works correctly.

Identify two different pieces of test data that can be used to test different outputs of the algorithm. Give the output from the program for each piece of test data.

[4]
Markscheme

Testing Questions

  1. GCSE
  2. /Computer Science
  3. /Testing

21 exam-style questions on OCR GCSE Computer Science Testing. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank