From e9985d4a30c99fb61920b6005cabfbfc514c9817 Mon Sep 17 00:00:00 2001 From: Andr3wGFX <159511664+Andr3wGFX@users.noreply.github.com> Date: Mon, 9 Feb 2026 19:02:55 -0700 Subject: [PATCH 1/2] Update lab_1a.py --- labs/lab_1/lab_1a.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/lab_1/lab_1a.py b/labs/lab_1/lab_1a.py index 9d15ec83..15983307 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -8,7 +8,7 @@ def main(): print("Hello World!") - name = "" # TODO: Insert your name between the double quotes + name = "Andrew Wu" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") From a716fceb8e90d3685a4e1abafa531cd489ed3b28 Mon Sep 17 00:00:00 2001 From: Andr3wGFX <159511664+Andr3wGFX@users.noreply.github.com> Date: Mon, 23 Mar 2026 18:10:27 -0700 Subject: [PATCH 2/2] Update lab_1b.py --- labs/lab_1/lab_1b.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index e58dd957..c9ddadaa 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -9,6 +9,23 @@ """ +def requestion_sanitized_number(promt: str) -> float: + """ + Function that takes in a prompt string, requests input from the user, and returns a sanitized float. + + Args: + promt (str): The prompt to display to the user when requesting input. + Returns: + float: The sanitized float input from the user. + """ + while True: + try: + user_input = input(promt) + sanitized_input = float(user_input) + return sanitized_input + except ValueError: + print("Invalid input. Please enter a valid number.") + def simple_calculator(operation: str, num1: float, num2: float) -> float: """ Function that takes in two numbers and an operation (add, subtract, multiply, divide), @@ -42,8 +59,8 @@ def main(): print(f"===== Simple Calculator =====") # Ask the user for sample input - num1 = float(input("Enter the first number: ")) - num2 = float(input("Enter the second number: ")) + num1 = requestion_sanitized_number ("Enter the first number: ") + num2 = requestion_sanitized_number ("Enter the second number: ") operation = input("Enter the operation (add, subtract, multiply, divide): ").strip().lower() # Perform the calculation and display the result