Name:............................................................................. Class:................... Mark:................
1. The following pseudocode tests how quickly a user can type a given sentence without
making any mistakes.
The statement time.clockTick() returns the number of seconds elapsed since the program
started followed by the number of characters in the sentence typed.
1 sentence = "The quick brown fox jumped over the lazy dog"
2 n = len(sentence)
3 print("Sentence to type: " + sentence)
4
5 mistakeMade = False
6
7 print("Press Enter when you're ready to start typing! Press Enter
when finished")
8 ready = input()
9 print("Go!")
10
11 startTime = time.clockTick()
12 mySentence = input()
13 finishTime = time.clockTick()
14 totalTime = finishTime - startTime
15
16 if mySentence != sentence:
17 mistakeMade = True
18 endif
19 if mistakeMade:
20 print("You made one or more errors")
21 else:
22 print(totalTime)
23 print(n)
24 endif
(a) What type of variable is each of the following? [4]
(i) mistakeMade
(ii) n
(iii) totalTime
(iv) sentence
(b) What does line 16 do? [2]
(c) Alter the program so that instead of storing the sentence “The quick brown fox jumped
over the lazy dog”, the user can enter the sentence on which they will be timed. [3]
1