Hi

import random import time # List of sample sentences for typing practice sentences = [ "The quick brown fox jumps over the lazy dog.", "Python is a powerful programming language.", "Practice makes a man perfect in typing skills.", "Hello world, welcome to the typing master challenge.", "Coding is fun and improves your typing speed." ] def typing_test(): print("Welcome to Typing Master Test!") print("Type the following sentence as fast and accurately as possible:") # Select a random sentence sentence = random.choice(sentences) print(f"\nSentence: {sentence}") # Start timer start_time = time.time() # Get user input user_input = input("\nYour typing: ") # End timer end_time = time.time() time_taken = end_time - start_time # Calculate accuracy correct_chars = sum(1 for a, b in zip(sentence, user_input) if a == b) accuracy = (correct_chars / len(sentence)) * 100 if len(sentence) > 0 else 0 # Calculate WPM (Words Per Minute) words_typed = len(user_input.split()) wpm = (words_typed / time_taken) * 60 print(f"\nTime taken: {time_taken:.2f} seconds") print(f"Accuracy: {accuracy:.2f}%") print(f"Words Per Minute (WPM): {wpm:.2f}") if accuracy >= 90 and wpm >= 40: print("Great job! You're on your way to becoming a typing master!") else: print("Keep practicing, bhai! Try again.") # Run the test typing_test()

Post a Comment

Previous Post Next Post