Reaction Time Tester
Look at the code provided below. It uses the time library to store the current time (as a number of seconds) at different lines of the code.
The code is executed very quickly, normally in just a few milliseconds, one line at a time. This is called sequencing. However from time to time your code is paused, waiting for the user to input a value. This is the case in Python every time you use the input instruction.
By recording the current time before and after an input instruction, we can then calculate how long it took for the user to type an answer. This is the approach used by the following Python program used to calculate your reaction time (how quickly will you press the return key).
Fast Typing Challenge
Adapt this script to measure how long it will take the end-user to type the entire alphabet (“abcdefghijklmnopqrstuvwxyz”).
Once the user has typed the alphabet, check that they typed it correctly. If not the user should try again until they type it right.
The program should then output:
- How many attempts they had,
- How long it took them in total,
- How long it took them on average per attempt,
- How long it took them on their last attempt (which is when they got it correct).
Add a menu system to offer three levels.
- Level 1: The user has to type the alphabet,
- Level 2: The user has to type the following quote: “The quick brown fox jumps over the lazy dog”.
- Level 3: A random quote is picked alongside a list of the following three pangrams(*):
- “The quick brown fox jumps over the lazy dog”
- “The five boxing wizards jump quickly”
- “Pack my box with five dozen liquor jugs”
(*)A pangram, or holoalphabetic sentence, includes every letter of the alphabet at least once. The most challenging pangrams are the ones with the fewest letters.
Solution...The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area