Skip to content

Commit 340d6eb

Browse files
authored
Merge pull request #22 from shwetmala55/main
Typing speed game
2 parents 8754ad0 + c8e5e46 commit 340d6eb

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# Typing Speed Game
3+
4+
This game tests the typing speed of user, it can
5+
also be used to improve typing speed,or can be played for fun.
6+
7+
## Screenshots
8+
![Getting Started](./type_speed_img.png)
9+
## Technologies used
10+
Python
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from time import time
2+
def tperror(prompt):
3+
global inwords
4+
words=prompt.split()
5+
errors=0
6+
for i in range(len(inwords)):
7+
if i in (0,len(inwords)-1):
8+
if inwords[i]==words[i]:
9+
continue
10+
else:
11+
errors=errors+1
12+
else:
13+
if inwords[i]==words[i]:
14+
if(inwords[i+1]==words[i+1])& (inwords[i-1]==words[i-1]):
15+
continue
16+
else:
17+
errors+=1
18+
else:
19+
errors+=1
20+
return errors
21+
22+
def speed(inprompt,stime,etime):
23+
global time
24+
global inwords
25+
26+
inwords=inprompt.split()
27+
twords=len(inwords)
28+
speed=twords/time
29+
return speed
30+
31+
32+
def elapsedtime(stime,etime):
33+
time=etime-stime
34+
return time
35+
36+
if __name__ == '__main__':
37+
prompt="Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly procedural), object-oriented and functional programming. It is often described as a batteries included language due to its comprehensive standard library."
38+
print("Type this->",prompt," ")
39+
input("Press Enter to check speed")
40+
41+
stime=time()
42+
inprompt=input()
43+
etime=time()
44+
45+
time=round(elapsedtime(stime,etime),2)
46+
speed=speed(inprompt,stime,etime)
47+
errors=tperror(prompt)
48+
49+
print("Total time elapsed: ",time,"seconds")
50+
print("Your avg typing speed is ",speed,"words per minute")
51+
print("with ",errors,"errors")
95.4 KB
Loading

0 commit comments

Comments
 (0)