From 3a060985c198ba3f126680470692dc7c4073542b Mon Sep 17 00:00:00 2001 From: Revati Natu Date: Thu, 18 Jun 2026 20:19:27 +0530 Subject: [PATCH 1/2] Add: Typing Speed Tester CLI --- Typing-Speed-Tester-CLI/README.md | 47 +++++++++++++ Typing-Speed-Tester-CLI/typing-test.py | 94 ++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 Typing-Speed-Tester-CLI/README.md create mode 100644 Typing-Speed-Tester-CLI/typing-test.py diff --git a/Typing-Speed-Tester-CLI/README.md b/Typing-Speed-Tester-CLI/README.md new file mode 100644 index 00000000..ad1ebae7 --- /dev/null +++ b/Typing-Speed-Tester-CLI/README.md @@ -0,0 +1,47 @@ +# ⌨️ Typing Speed Tester CLI + +A terminal-based typing speed tester that measures your WPM and accuracy — no browser, no setup, just Python. + +## Features + +- Randomly selects a sentence each round +- Measures **WPM** (words per minute) and **accuracy** (per word) +- Color-coded feedback — green for correct words, red for mistyped ones +- Session summary with averages and best score after multiple rounds + +## Demo + +``` +⌨ Typing Speed Tester + +Type the sentence below as fast and accurately as you can. + +─────────────────────────────────────────────────────── +coding is the closest thing we have to a superpower +─────────────────────────────────────────────────────── + +> coding is the closest thing we have to a superpower + + WPM : 72 + Accuracy : 100% (9/9 words correct) + Time : 7.48s +``` + +## Requirements + +Python 3.x — no external libraries needed. + +## Usage + +```bash +python typing_speed_tester.py +``` + +Type the displayed sentence and press Enter. Type `quit` to end the session. + +## How It Works + +- Timer starts when you press Enter to begin +- Each word in your input is compared against the original +- WPM is calculated as `(word_count / elapsed_seconds) * 60` +- Accuracy is `correct_words / total_words * 100` \ No newline at end of file diff --git a/Typing-Speed-Tester-CLI/typing-test.py b/Typing-Speed-Tester-CLI/typing-test.py new file mode 100644 index 00000000..44d4c7f6 --- /dev/null +++ b/Typing-Speed-Tester-CLI/typing-test.py @@ -0,0 +1,94 @@ +import time +import random +import sys + +SENTENCES = [ + "the quick brown fox jumps over the lazy dog", + "coding is the closest thing we have to a superpower", + "practice makes perfect but nobody is perfect so why practice", + "python is a versatile language used in web development and data science", + "open source contributions help developers grow and build their portfolios", + "artificial intelligence is transforming the way humans interact with machines", + "the best way to predict the future is to create it yourself", + "every expert was once a beginner who refused to give up", + "simplicity is the ultimate sophistication in software design", + "debugging is twice as hard as writing the code in the first place", + "the efficiency we have at removing trash has made creating trash more acceptable", + "the only way to do great work is to love what you do", +] + +def colored(text, code): return f"\033[{code}m{text}\033[0m" +def green(t): return colored(t, "92") +def red(t): return colored(t, "91") +def cyan(t): return colored(t, "96") +def bold(t): return colored(t, "1") + +def compare(original, typed): + result, correct = "", 0 + words_o, words_t = original.split(), typed.split() + for i, word in enumerate(words_o): + typed_word = words_t[i] if i < len(words_t) else "" + if typed_word == word: + result += green(word) + " " + correct += 1 + else: + result += red(word) + " " + return result.strip(), correct, len(words_o) + +def run(): + print(bold(cyan("\n⌨ Typing Speed Tester\n"))) + print("Type the sentence below as fast and accurately as you can.") + print("Press Enter when done. Type 'quit' to exit.\n") + + scores = [] + while True: + sentence = random.choice(SENTENCES) + print(bold("─" * 55)) + print(f"\n{cyan(sentence)}\n") + print(bold("─" * 55)) + + try: + input("Press Enter to start...") + print("\033[1A\033[K", end="") # clears the prompt line + start = time.time() + typed = input("> ").strip() + elapsed = time.time() - start + except (KeyboardInterrupt, EOFError): + break + + if typed.lower() == "quit": + break + + if elapsed < 0.5: + print(red("Too fast — did you actually type that?\n")) + continue + + wpm = round((len(sentence.split()) / elapsed) * 60) + result, correct, total = compare(sentence, typed) + accuracy = round((correct / total) * 100) + + print(f"\n{result}\n") + print(f" {bold('WPM')} : {green(str(wpm))}") + print(f" {bold('Accuracy')}: {green(str(accuracy) + '%')} ({correct}/{total} words correct)") + print(f" {bold('Time')} : {elapsed:.2f}s\n") + + scores.append((wpm, accuracy)) + + again = input("Try again? (y/n): ").strip().lower() + print() + if again != "y": + break + + if scores: + avg_wpm = round(sum(s[0] for s in scores) / len(scores)) + avg_acc = round(sum(s[1] for s in scores) / len(scores)) + print(bold(cyan(" Session Summary: "))) + print(f" Rounds : {len(scores)}") + print(f" Avg WPM : {green(str(avg_wpm))}") + print(f" Avg Acc : {green(str(avg_acc) + '%')}") + best = max(scores, key=lambda s: s[0]) + print(f" Best WPM : {green(str(best[0]))} (at {best[1]}% accuracy)") + print("\nGood session. See ya! \n") + +if __name__ == "__main__": + run() \ No newline at end of file From eb9470d21ab65de99358c703037271abbfd54140 Mon Sep 17 00:00:00 2001 From: Revati Natu Date: Thu, 18 Jun 2026 20:24:56 +0530 Subject: [PATCH 2/2] Update: Add Typing Speed Tester CLI to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index edeffb20..099895d3 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Browse our collection of 100+ mini-projects organized by category: - [Black Jack](./Black_Jack_Game) - Card game simulation - [Russian Roulette](./Russian%20Roulette) - Probability game - [Slot Machine](./slot-machine) - Casino-style slot game +- [Typing Speed Tester CLI](./Typing-Speed-Tester-CLI) - Terminal-based WPM and accuracy tester game ### Web Development - [Beautiful JS Clock](./Beautiful%20JS%20Clock) - Animated clock interface