
Every individual who owns an electronic gadget usually types in their respective device, whether a laptop, a phone, or a PC. In the modern world, typing through projects is the more utilized and convenient approach for completing a variety of tasks.
Personally, I type quite a lot and type different sorts of material and content. The range of content varies from typing articles on Medium, analyzing and coding Data Science projects, writing important emails, or simply browsing through the internet. Although writing helps to generate ideas and think effectively, I cannot deny that I spend more time typing than writing.
Whether people fall in the same spectrum as me or a different case for different minds and individuals, it is always a great idea to stay on your ‘A’ game when typing. In this project, we will design a straightforward speed typing test with Python to help evaluate your accuracy, error rate, and typing speed.
We will develop this project on a console interface and print the error rate and overall score in words per second. For more curious developers, I recommend checking out the advanced GUI interface development with Python, through which the project can gain a more appealing and aesthetic look. I have provided the link for the following article below.
Developing the speed testing project:

In this section of the article, we will be developing the "speed test" software to report the typing scores and error rates while typing for the respective users. The test should probably be taken multiple times to gain an average rating for determining the true values accordingly.
There are several different ways to approach this project, and I will use the most straightforward and simplest way to achieve the desired solutions. I would recommend installing the following library provided below to simplify the process.
pip install wonderwords
You can learn more about this library through the official pip install Python package index website from the following link or through the following quick start documentation website. To make natural language processing tasks easier to understand, I suggest checking out one of my previous articles on regular expression operators from the link provided below.
Natural Language Processing Made Simpler with 4 Basic Regular Expression Operators!
Importing the required libraries:
The first step to building our speed test software with Python is to import all the necessary libraries. We will use the wonder words library to import the random sentence class, which will allow us to generate random sentences to be displayed to the user for typing. I prefer using this library as a more generic approach to randomly generate different paragraphs each time the speed test needs to be performed.
For developers who prefer a varied approach so as to not use the previously mentioned library, we can make use of the random library and type your own sentences and make your own lists. The choice functionality in the random library is useful in incorporating a random selection of the various paragraph choice options to be displayed to the tester. The time library module is essential to track the typing speed of the user. Below is the list of all the required library imports.
from wonderwords import RandomSentence
import random
import time
Random sentence generation:
Once all the necessary libraries are imported, we can proceed to the next step. We will create a sentence list and sentence paragraph as a string variable. We will then create a for loop through which we will use the random sentence module from the "wonder words" library. Once the following class is assigned to the desired variable, we can generate random sentences.
Each of the randomly generated sentences is appended to a list and then converted into a string paragraph where all the paragraphs with the respective sentences are stored together. These randomly generated paragraphs will be displayed to the user. Once displayed, they can be typed to test the appropriate speed and error rate.
sent_list = []
sent_para = ""
for i in range(5):
sent = RandomSentence()
random_sent = sent.sentence()
sent_list.append(random_sent)
sent_para += random_sent + " "
Error rate computation:
Once the random paragraph is stored in a variable, we can proceed to define the next step of computing the error rate of the tester typing. I am using a simple approach to compute the error rate for the purpose of simplicity in this project. Note that this might not be the most efficient method for computing the error rate appropriately. I will cover more on the improvements and further advancements in the upcoming section.
In this method, we compute the length of the sentence paragraph and create a loop in this range. We will then compare each typed in the original sentence paragraph versus the typed paragraph. Each time the characters don’t add up, an error count is added. The total error percentage is computed by dividing the error count by the total length and multiplying the same by 100. The code snippet for the following function is provided below.
def error_rate(sent_para, typed_para):
error_count = 0
length = len(sent_para)
for character in range(length):
try:
if sent_para[character] != typed_para[character]:
error_count += 1
except:
error_count += 1
error_percent = error_count/length * 100
return error_percent
Final score and error percent:
In the final step of this project, we will type a sentence signifying that the speed test is starting and the appropriate paragraph must be accurately printed in due time with the least errors to achieve the best scores. The start time and end time are recorded until the respective paragraph is input by the user. The overall time taken is computed by subtracting the start time from the end time. The error rate is computed by the previously defined function in this section of the article.
I have added an additional step of creating an if loop to measure the error percent of the typed sentence. If the error percentage exceeds 50, then the score computed may not be accurate, and a re-test might be required. If the error percent is less than 50 percent, we can report the speed in words per second and the total words per second. Below is the code block for performing the speed test operation.
print("Type the below paragraph as quickly as possible with as few mistakes to get a high score: n")
print(sent_para)
print("n")
start_time = time.time()
typed_para = input()
end_time = time.time()
time_taken = end_time - start_time
error_percent = error_rate(sent_para, typed_para)
print("n")
if error_percent > 50:
print(f"Your error rate {error_percent} was quite high and hence your accurate speed could not be computed.")
else:
speed = len(typed_para)/time_taken
print("******YOUR SCORE REPORT******")
print(f"Your speed is {speed} words/sec")
print(f"The error rate is {error_percent}")
The speed testing project is now complete. The readers can proceed to perform their own tests and check their typing speeds! However, for more curious and interested developers, we will perform a test run. I will also suggest a few additional improvements to make this project even more intriguing and user-friendly in the upcoming section.
Test run and additional improvements:

Once you run the program in your respective console (I am using the visual studio code editor, but the command prompt can also be used), you should be able to test the working code accordingly. In the above screenshot, the readers can notice the random sentence that is generated by the wonder words library, and below the original paragraph is the paragraph typed by me.
Once I click enter after typing the required paragraph, we can read the score report accordingly. From the above screenshot, we can notice that my word speed is approximately 4.3 words per second with an error rate of 0.59. For more precise and accurate test scores, I recommend running the above program and taking an average of at least five test runs.
Another important topic that we will cover in this section is the different improvements to be made to further enhance the functionality and style aspect of this project. Some of the suggestions are as follows:
- For a more customizable approach to generate sentences, either using your own custom sentences and the random choice function is a good option. However, if the readers want to go one step ahead, the Open AI offers a great option for high-level story integration.
- The computation for the error rate might be slightly flawed as one character error might lead to several faults. A better approach might be to consider all the words in both the original paragraph and the typed paragraph and then compare the two lists.
- A final tip would be to transfer the entire project onto a GUI interface, as a console interface can be lackluster. I recommend checking out my previous articles on GUIs for a quick start on the starter codes for some of the noteworthy GUI options available in Python.
7 Best UI Graphics Tools For Python Developers With Starter Codes
Conclusion:

"Typing is the future of talking and to don’t forgot and brother of feature."
- Deyth Banger
Typing is now a significant part of our lives and something that we constantly do as a necessity. While we type quite a lot, and it becomes more natural to us as we do it more and more, one might be curious as to how quickly they type and how accurately they can do so. A good method to find out about this is by improving your typing speeds constantly for higher Productivity.
In this project, we developed a speed testing software with Python that enables us to enter the specific paragraph suggested to us, and upon typing the following paragraph with an error percent less than 50, we are able to receive our typing scores and percentage error. We also discussed the additional improvements and advancements that can be made to further enhance this project.
If you want to get notified about my articles as soon as they go up, check out the following link to subscribe for email recommendations. If you wish to support other authors and me, then subscribe to the below link.
If you have any queries related to the various points stated in this article, then feel free to let me know in the comments below. I will try to get back to you with a response as soon as possible. Check out some of my other articles that my viewers also enjoy reading!
The Ultimate Replacements to Jupyter Notebooks
7 Best Research Papers To Read To Get Started With Deep Learning Projects
Thank you all for sticking on till the end. I hope all of you enjoyed reading the article. Wish you all a wonderful day!