Code Time 212
Code Time 212
import random
import os
sentences = [
"The quick brown fox jumps over the lazy dog.",
"Python is a great programming language for beginners and experts.",
"Artificial intelligence is transforming the way we live and work.",
"Typing fast and accurately is a valuable skill in the digital age.",
"Never gonna give you up, never gonna let you down.",
"Sphinx of black quartz, judge my vow.",
"Pack my box with five dozen liquor jugs.",
"A journey of a thousand miles begins with a single step.",
"All that glitters is not gold.",
"Time flies like an arrow; fruit flies like a banana."
]
def clear_screen():
os.system("cls" if os.name == "nt" else "clear")
def welcome():
clear_screen()
print("┌────────────────────────────────────┐")
print("│ 🧠 TYPE RACER 🏁 │")
print("└────────────────────────────────────┘")
input("Press Enter to start...")
def countdown():
for i in range(3, 0, -1):
clear_screen()
print(f"Starting in {i}...")
time.sleep(1)
def choose_sentence():
return random.choice(sentences)
def play_round():
sentence = choose_sentence()
clear_screen()
print("Type the following sentence as fast as you can:")
print()
print(f"📝: {sentence}")
print()
input("Press Enter when ready...")
clear_screen()
print(f"📝: {sentence}")
print()
start = time.time()
typed = input("Your input: ")
end = time.time()
print("\nResults:")
print(f" Time: {round(end - start, 2)} seconds")
print(f"📈 WPM: {wpm}")
print(f"🎯 Accuracy: {accuracy}%")
print(f"❌ Errors: {errors}")
def main_menu():
while True:
clear_screen()
print("=== Type Racer Main Menu ===")
print("1. Play")
print("2. About")
print("3. Exit")
choice = input("Choose an option: ")
if choice == "1":
welcome()
countdown()
play_round()
input("\nPress Enter to return to the menu...")
elif choice == "2":
clear_screen()
print("Type Racer")
print("Version: 1.0")
print("Made with ❤️ in Python")
print("\nRace against yourself to improve typing speed and accuracy!")
input("\nPress Enter to return to the menu...")
elif choice == "3":
clear_screen()
print("Goodbye 👋")
time.sleep(1)
break
else:
input("Invalid option. Press Enter to try again...")
if __name__ == "__main__":
main_menu()