diff --git a/pySure/README.md b/pySure/README.md new file mode 100644 index 0000000..4a742f1 --- /dev/null +++ b/pySure/README.md @@ -0,0 +1,11 @@ +# Temperature Converter + +## 🚀 What the Project Does +A simple python program that converts either Fahrenheit to Celsius or Celsius to Fahrenheit. + +## 🛠️ How to Run +Make sure you have Python 3 installed. + +Then run the command in terminal or command prompt. +```bash +python temp.py diff --git a/pySure/temp.py b/pySure/temp.py index d9ecdd4..e1d8c5a 100644 --- a/pySure/temp.py +++ b/pySure/temp.py @@ -1,3 +1,6 @@ +C_CONSTANT = 9/5 +F_CONSTANT = 32 + # Choose the unit of temperature conversion unit = input("Choose the unit of temperature conversion (C/F): ").strip().upper() @@ -6,11 +9,11 @@ # Function to convert Celsius to Fahrenheit def temp_c_to_f(c): - return (c*9/5) + 32 + return (c*C_CONSTANT) + F_CONSTANT # Function to convert Fahrenheit to Celsius def temp_f_to_c(f): - return (f - 32) * 5/9 + return (f - F_CONSTANT) * 1/C_CONSTANT # Check the chosen unit and perform the conversion if unit == "C": diff --git a/week1_projects/KyleighHarkless/README.md b/week1_projects/KyleighHarkless/README.md new file mode 100644 index 0000000..c3a92bb --- /dev/null +++ b/week1_projects/KyleighHarkless/README.md @@ -0,0 +1,23 @@ +# Typing Speed Tester + +A simple Python program that measures how fast and accurately you can type a given sentence. + +## Features + +- Displays a sentence prompt for the user to type. +- Records the time taken to type the sentence. +- Calculates typing accuracy based on how many characters match the prompt. +- Displays a neat summary including: + - Time taken (seconds) + - Accuracy (%) + +> Optionally, you could extend this to multiple prompts or measure words per minute. + +## How to Run + +1. Make sure you have Python installed (version 3.x recommended). +2. Clone or download this repository. +3. Run the script: + +```bash +python typing_speed_tester.py \ No newline at end of file diff --git a/week1_projects/KyleighHarkless/Typing_speed_tester.py b/week1_projects/KyleighHarkless/Typing_speed_tester.py new file mode 100644 index 0000000..a979581 --- /dev/null +++ b/week1_projects/KyleighHarkless/Typing_speed_tester.py @@ -0,0 +1,58 @@ +import time + +def typing_speed_test(): + start = input("\nWelcome to the typing test!\nPress 'enter' to start! ") + + print("\nvvv Type this sentence as fast as you can! vvv\n ----------------------------------------") + + prompt1 = "The quick brown fox jumps over the lazy dog." + prompt2 = "Despite the heavy rain, Julia sprinted across the crowded street—dodging cars, " \ + "splashing through puddles, and laughing the entire way." + + print(f"{prompt1}\n ----------------------------------------\n") + + start1 = time.time() + typed_response1 = input(">>> ") + end1 = time.time() + + secs1 = (end1 - start1) + + accuracy1 = accuracy_checker(prompt1, typed_response1) + + print(f"It took you, {secs1:.2f} seconds!") + print(f"Your accuracy: {accuracy1:.2f}%") + + if secs1 < 12 and accuracy1 > 60: + start = input("\nYou're ready for a harder challenge!\nPress 'enter' to start! ") + print("\nvvv Type this sentence as fast as you can! vvv\n ----------------------------------------") + print(f"{prompt2}\n ----------------------------------------") + + start2 = time.time() + typed_response2 = input(">>> ") + end2 = time.time() + + secs2 = end2 - start2 + + accuracy2 = accuracy_checker(prompt2, typed_response2) + + print(f"It took you, {secs2:.2f} seconds!") + print(f"Your accuracy: {accuracy2:.2f}%\n Great job!") + + + else: + print("\nNot too bad try again and get better results for a harder challenge!") + +def accuracy_checker(prompt:str, user_input:str): + """ + Returns accuracy as the percentage of characters in the prompt + that match the user's input (position by position). + """ + prompt_words = prompt.strip().split() + user_words = user_input.strip().split() + + correct_words = sum(1 for p, u in zip(prompt_words, user_words) if p == u) + accuracy = (correct_words / len(prompt_words)) * 100 if len(prompt_words) > 0 else 0.0 + + return accuracy + +typing_speed_test() \ No newline at end of file