Problem 4 (100pts): wpm
Implement wpm
, which computes the words per minute, a measure of typing speed, given a string typed
and the amount of elapsed
time in seconds. Despite its name, words per minute is not based on the number of words typed, but instead the number of characters, so that a typing test is not biased by the length of words. The formula for words per minute is the ratio of the number of characters (including spaces) typed divided by 5 (a typical word length) to the elapsed time in minutes.
For example, the string "I am glad!"
contains three words and ten characters (not including the quotation marks). The words per minute calculation uses 2 as the number of words typed (because 10 / 5 = 2). If someone typed this string in 30 seconds (half a minute), their speed would be 4 words per minute.
# Test your implementation
python ok -q 04
Time to test your typing speed! You can use the command line to test your typing speed on paragraphs about a particular topic. For example, the command below will load paragraphs about cats or kittens. See the run_typing_test
function for the implementation if you're curious (but it is defined for you).
python cats.py -t cats kittens
You can try out the web-based graphical user interface (GUI) using the following command.
python gui.py
Congratulations! You have finished Phase 1 of this project!