-
Notifications
You must be signed in to change notification settings - Fork 0
/
typingSpeed.py
38 lines (30 loc) · 924 Bytes
/
typingSpeed.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
import random as r
from time import *
def mistake(partest, usertest):
error = 0
for i in range(len(partest)):
try:
if partest[i] != usertest[i]:
error = error + 1
except:
error = error + 1
return error
def speed_time(time_s, time_e, userinput):
time_delay = time_e - time_s
time_R = round(time_delay, 2)
speed = len(userinput) / time_R
return round(speed)
test = ["hare krishna hare krishna krishna krishna hare hare hare ram hare ram ram ram hare hare",
"om shri mahaganapataye namah",
"har har mahadev jay shiv sambhu",
"jay mata di bolo jay mata di"]
test1 = r.choice(test)
print("***** Typing Speed *****")
print(test1)
print()
print()
time1 = time()
testinput = input(" Enter : ")
time2 = time()
print('Speed: ', speed_time(time1, time2, testinput), "w/sec")
print("Error: ", mistake(test1, testinput))