-
Notifications
You must be signed in to change notification settings - Fork 0
/
Typing_Speed_Test.py
47 lines (34 loc) · 1.04 KB
/
Typing_Speed_Test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#Typing speed test
import time
import math
correct,incorrect = 0,0
print("Start typing when the timer ends")
timer = 5
while timer > 0:
print(timer)
time.sleep(1)
timer-=1
t1 = time.time()
sentence = input("Click enter when you're done !! \n")
t2 = time.time()
sentence_list = sentence.split()
from autocorrect import Speller
spell = Speller(lang='en')
incorrectWords = []
for word in sentence_list:
if spell(word) == word:
correct += 1
else:
incorrect +=1
incorrectWords.append(word)
speed = (len(sentence_list) * 60)/(t2-t1)
if len(sentence) == 0:
print("You haven't entered anything")
else:
print("You have typed total",len(sentence_list),"words in",math.floor(t2-t1),"sec")
print("Your typing speed is",math.floor(speed),"WPM")
print("Correct words",correct)
print("Incorrect words",incorrect)
if len(incorrectWords) != 0:
print(incorrectWords)
print("Accuracy",correct/(incorrect+correct) * 100,"%")