Advertisement
TTpocToXaKep

Typing speed test

Jan 31st, 2023
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. # https://pastebin.com/u/TTpocToXaKep
  2. import time
  3.  
  4. def typing_speed_test():
  5.     words = "The quick brown fox jumps over the lazy dog."
  6.     print("Type the following sentence:")
  7.     print(words)
  8.  
  9.     start_time = time.time()
  10.     user_input = input("Your response: ")
  11.     end_time = time.time()
  12.  
  13.     total_time = end_time - start_time
  14.     accuracy = (len(words) - (len(words) - len(user_input))) * 100 / len(user_input)
  15.     wpm = len(user_input) / 5 / total_time * 60
  16.  
  17.     print("Your total time is %s seconds" % total_time)
  18.     print("Your accuracy rate is %s %%" % accuracy)
  19.     print("Your words per minute rate is %s wpm" % wpm)
  20.  
  21. typing_speed_test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement