From 3032922e5c5149eed4337693d31aebc5602c4dcd Mon Sep 17 00:00:00 2001 From: EricXu23 Date: Fri, 20 Mar 2026 14:54:31 -0400 Subject: [PATCH 1/6] Update lab_1a.py Updated my name into lab_1a code --- 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..e29b5d22 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 = "Eric Xu" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") From 35e281978314bd480d9e94f43284093d9982db4a Mon Sep 17 00:00:00 2001 From: EricXu23 <148099186+EricXu23@users.noreply.github.com> Date: Fri, 20 Mar 2026 15:02:45 -0400 Subject: [PATCH 2/6] Add robot speed comment to lab_1a.py Added a comment about robot speed in the lab description. --- labs/lab_1/lab_1a.py | 1 + 1 file changed, 1 insertion(+) diff --git a/labs/lab_1/lab_1a.py b/labs/lab_1/lab_1a.py index 9d15ec83..407746c4 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -3,6 +3,7 @@ The first lab in the BWSI CSS course. To complete this lab, fill out the variable on line 10 with your name. Then, save the code, add it to the staging area, and commit it to the Git tree. +This is to simulate a change made on a robot: robot_speed = 5 # m/s """ def main(): From 2c4f7cc56dd882fd068017bdaa211af3f8083845 Mon Sep 17 00:00:00 2001 From: EricXu23 <148099186+EricXu23@users.noreply.github.com> Date: Fri, 20 Mar 2026 15:06:08 -0400 Subject: [PATCH 3/6] Change robot speed to 3 m/s Updated robot speed from 5 m/s to 3 m/s. --- 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 407746c4..ceef2cba 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -3,7 +3,7 @@ The first lab in the BWSI CSS course. To complete this lab, fill out the variable on line 10 with your name. Then, save the code, add it to the staging area, and commit it to the Git tree. -This is to simulate a change made on a robot: robot_speed = 5 # m/s +This is to simulate a change made on a robot: robot_speed = 3 # m/s """ def main(): From e5f1cabca38156b75c95b45cbe465b87bc7fe367 Mon Sep 17 00:00:00 2001 From: EricXu23 Date: Fri, 20 Mar 2026 15:07:29 -0400 Subject: [PATCH 4/6] Update lab_1a.py Updated speed from 5 to 8 --- 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 2c3316fc..82528f91 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -3,7 +3,7 @@ The first lab in the BWSI CSS course. To complete this lab, fill out the variable on line 10 with your name. Then, save the code, add it to the staging area, and commit it to the Git tree. -This is to simulate a change made on a robot: robot_speed = 5 # m/s +This is to simulate a change made on a robot: robot_speed = 8 # m/s """ def main(): From 3ee1ac589daffcddb22d5d90330f9ee6fe5d9fc8 Mon Sep 17 00:00:00 2001 From: EricXu23 Date: Fri, 20 Mar 2026 15:19:27 -0400 Subject: [PATCH 5/6] Update lab_1b.py Fixed a exception error bug. bad input --- labs/lab_1/lab_1b.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index e58dd957..a6df72e7 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -8,6 +8,14 @@ and prints the result to the terminal window. """ +def request_sanatized_num(prompt: str) -> float: + while True: + try: + number = float(input(prompt)) + return number + except ValueError: + print("Invalid input number. Please enter a valid number.") + def simple_calculator(operation: str, num1: float, num2: float) -> float: """ @@ -42,8 +50,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 = request_sanatized_num("Enter the first number: ") + num2 = request_sanatized_num("Enter the second number: ") operation = input("Enter the operation (add, subtract, multiply, divide): ").strip().lower() # Perform the calculation and display the result From 17d07ee9af849e15390923feb480fb33e7e7ecc9 Mon Sep 17 00:00:00 2001 From: EricXu23 Date: Fri, 20 Mar 2026 15:24:27 -0400 Subject: [PATCH 6/6] Update lab_1b.py Sanatized the operations --- labs/lab_1/lab_1b.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index a6df72e7..d5ebe3df 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -16,7 +16,16 @@ def request_sanatized_num(prompt: str) -> float: except ValueError: print("Invalid input number. Please enter a valid number.") - +def request_sanitized_operation(prompt: str) -> str: + valid_operations = {"add", "subtract", "multiply", "divide"} + + while True: + operation = input(prompt).strip().lower() + if operation in valid_operations: + return operation + else: + print("Invalid operation. Please choose from add, subtract, multiply, or divide.") + def simple_calculator(operation: str, num1: float, num2: float) -> float: """ Function that takes in two numbers and an operation (add, subtract, multiply, divide),