Testing
6
0/4

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]

Testing Questions

Practise OCR GCSE Computer Science Testing with exam-style questions for GCSE Computer Science. 21 questions, matched to the OCR GCSE Computer Science (J277) specification and written in Component 01 and Component 02 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Testing Questions

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