diff --git a/Python Projects/Typing_speed_game/README.md b/Python Projects/Typing_speed_game/README.md new file mode 100644 index 00000000..55a9e2e6 --- /dev/null +++ b/Python Projects/Typing_speed_game/README.md @@ -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 \ No newline at end of file diff --git a/Python Projects/Typing_speed_game/speed.py b/Python Projects/Typing_speed_game/speed.py new file mode 100644 index 00000000..6c620dc1 --- /dev/null +++ b/Python Projects/Typing_speed_game/speed.py @@ -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") \ No newline at end of file diff --git a/Python Projects/Typing_speed_game/type_speed_img.png b/Python Projects/Typing_speed_game/type_speed_img.png new file mode 100644 index 00000000..ee875ca1 Binary files /dev/null and b/Python Projects/Typing_speed_game/type_speed_img.png differ