Creating A Wpm Counter For A Phrase Then Output The Time Taken
So I want to create a simple program using the time.monotonic() function to prompt before and after the user has has typed the phrase then give the avg words per minutes along with
Solution 1:
import time
string = "The quick brown fox jumps over the lazy dog"
word_count = len(string.split())
You can prepare the user with some intro
whilestr(raw_input('Enter "yes" when you are ready')) <> 'yes':
str(raw_input('Enter "yes" when you are ready'))
Then you start your timer
t0 = time.time() #start timeinputText = str(raw_input('Enter the phrase :"%s" as fast as possible' % string))
t1 = time.time() #stop time
Then you can count the percentage of correctly entered words somehow
acc = len(set(inputText.split()) & set(string.split()))
acc = acc/word_count
timeTaken = t1 - t0
wordPM = (word_count/timeTaken)
print wordPM, acc
Post a Comment for "Creating A Wpm Counter For A Phrase Then Output The Time Taken"