Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cb7a633

Browse files
Merge pull request avinashkranjan#795 from dhriti987/typing_speed
Typing Speed test file added
2 parents ec7c886 + 0bd2a1c commit cb7a633

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

‎Typing-Speed-Test/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Typing Speed Test
2+
3+
* speed_test.py is a program to test ( hence improve) your typing speed
4+
* It calculates Word per minute, Acuraccy, and Time taken by you to type the sentence shown on your screen.
5+
6+
## Setup Instructions
7+
* Run using following command
8+
9+
```
10+
python speed_test.py
11+
```
12+
13+
## Author
14+
* Dhritiman

‎Typing-Speed-Test/sentences.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
We all agreed; it was a magnificent evening.
2+
The governor was indicted for threatening to veto funding for a unit that investigates corruption unless a top Democrat resigned.
3+
The work was started soon after annexation, but only finished in 1859.
4+
The conservative party is very vague on its own agenda dealing with the election.
5+
We have also revitalized American diplomacy and strengthened our alliances.
6+
There was a potato famine in ireland, similar to the one in the us in the great depression.
7+
Obama was incumbent in the united states as a politician.
8+
Whenever inflation is involved with a economy of a country good things never proceed in upcoming events.
9+
I stood with a tape recorder, listening to men denounce the liberal media controlled by Republicans.
10+
The ham, green beans, mashed potatoes, and corn are gluten-free.

‎Typing-Speed-Test/speed_test.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import tkinter as tk
2+
import random
3+
import timeit
4+
5+
start_time = 0
6+
7+
def get_sentence():
8+
global sentence,sentence_length,sentence_words
9+
Reset()
10+
with open("./Typing-Speed-Test/sentences.txt","r") as f:
11+
sentences = f.readlines()
12+
sentence = random.choice(sentences).rstrip()
13+
sentence_label.config(text = sentence)
14+
sentence_length = len(sentence)
15+
sentence_words = len(sentence.split())
16+
print(sentence_length)
17+
18+
def result():
19+
time_taken = round(timeit.default_timer() - start_time)
20+
typed_text = text.get()
21+
wpm = round((sentence_words/time_taken)*60)
22+
count = 0
23+
for index,char in enumerate(typed_text):
24+
if sentence[index] == char:
25+
count+=1
26+
accu = round((count/sentence_length)*100)
27+
28+
Speed.config(text = f"Speed: {wpm} WPM")
29+
Accuracy.config(text = f"Accuracy: {accu}")
30+
Time.config(text = f"Time: {time_taken} sec")
31+
32+
33+
def check(text):
34+
global start_time
35+
if start_time==0 and len(text.get())==1:
36+
start_time = timeit.default_timer()
37+
elif len(text.get()) == sentence_length:
38+
typing_box.config(state = tk.DISABLED)
39+
result()
40+
41+
def Reset():
42+
global start_time
43+
typing_box.config(state = tk.NORMAL)
44+
typing_box.delete(0,tk.END)
45+
start_time=0
46+
47+
Speed.config(text = f"Speed: 00 WPM")
48+
Accuracy.config(text = f"Accuracy: 00")
49+
Time.config(text = f"Time: 0 sec")
50+
51+
52+
window = tk.Tk()
53+
window.geometry("900x600+300+100")
54+
window.title("Typing Speed Test")
55+
bg_color = "#00154D"
56+
window.config(bg = bg_color)
57+
58+
tk.Label(window,text="Typing Speed Test", anchor = tk.CENTER,font = ("times new roman",50,"bold"),bg=bg_color,fg = "#F2BC90").pack(side=tk.TOP)
59+
60+
sentence_label = tk.Label(window,text="a set of words that is complete in itself, typically containing a subject and predicate, conveying a statement, question, exclamation, or command, and consisting of a main clause and sometimes one or more subordinate clauses.",wraplength=700,anchor = tk.CENTER,font = ("arial",20,"bold"),bg=bg_color,fg="#ffffff",width=40,justify=tk.LEFT)
61+
sentence_label.pack(pady=40)
62+
text = tk.StringVar()
63+
text.trace("w",lambda name,index,mode,text=text: check(text))
64+
typing_box = tk.Entry(window,font = ("arial",20,"bold"),width=40,textvariable = text)
65+
typing_box.place(x=150,y=360)
66+
67+
reset_button = tk.Button(window,text = "Reset" ,font = ("arial",18,"bold"),width=12,command= Reset)
68+
reset_button.place(x=120,y=450)
69+
change_button = tk.Button(window,text = "Change Text" ,font = ("arial",18,"bold"),width=12,command = get_sentence)
70+
change_button.place(x=360,y=450)
71+
result_button = tk.Button(window,text = "Result" ,font = ("arial",18,"bold"),width=12,command =result)
72+
result_button.place(x=600,y=450)
73+
74+
Speed = tk.Label(window,text = "Speed: 00 WPM",font = ("arial",15,"bold"),bg=bg_color,fg="#ffffff")
75+
Speed.place(x=120,y=530)
76+
Accuracy = tk.Label(window,text = "Accuracy: 00",font = ("arial",15,"bold"),bg=bg_color,fg="#ffffff")
77+
Accuracy.place(x=380,y=530)
78+
Time = tk.Label(window,text = "Time: 0 sec",font = ("arial",15,"bold"),bg=bg_color,fg="#ffffff")
79+
Time.place(x=620,y=530)
80+
81+
get_sentence()
82+
window.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /