Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Python Projects/Typing_speed_game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# Typing Speed Game

This game tests the typing speed of user, it can
also be used to improve typing speed,or can be played for fun.

## Screenshots
![Getting Started](./type_speed_img.png)
## Technologies used
Python
51 changes: 51 additions & 0 deletions Python Projects/Typing_speed_game/speed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from time import time
def tperror(prompt):
global inwords
words=prompt.split()
errors=0
for i in range(len(inwords)):
if i in (0,len(inwords)-1):
if inwords[i]==words[i]:
continue
else:
errors=errors+1
else:
if inwords[i]==words[i]:
if(inwords[i+1]==words[i+1])& (inwords[i-1]==words[i-1]):
continue
else:
errors+=1
else:
errors+=1
return errors

def speed(inprompt,stime,etime):
global time
global inwords

inwords=inprompt.split()
twords=len(inwords)
speed=twords/time
return speed


def elapsedtime(stime,etime):
time=etime-stime
return time

if __name__ == '__main__':
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."
print("Type this->",prompt," ")
input("Press Enter to check speed")

stime=time()
inprompt=input()
etime=time()

time=round(elapsedtime(stime,etime),2)
speed=speed(inprompt,stime,etime)
errors=tperror(prompt)

print("Total time elapsed: ",time,"seconds")
print("Your avg typing speed is ",speed,"words per minute")
print("with ",errors,"errors")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.