From 0307eccd6ad5f3deaef915494be53775b0bd58f0 Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 16:30:54 -0400 Subject: [PATCH 01/10] Update lab_1a.py Added my name to the empty space --- 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..2f016b1b 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 = "Sylvie Yao" print(f"{name}, Welcome to the CSS course!") From 5c98552930b133b5484f511d9d080e9d600eb95a Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 16:37:33 -0400 Subject: [PATCH 02/10] Update lab_1a.py Added my personal 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 2f016b1b..593fc9f1 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -11,6 +11,7 @@ def main(): name = "Sylvie Yao" print(f"{name}, Welcome to the CSS course!") + print("My name is Sylvie. I am junior from New Jersey. I like to play tennis and build puzzles!") if __name__ == "__main__": main() From 4814c6c10ce9304cd8a6132d66846888f4145304 Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 16:46:11 -0400 Subject: [PATCH 03/10] 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 593fc9f1..8cf182b5 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -1,4 +1,4 @@ -""" +"This is to simulate a change made on a robot: robot_speed = 5 # m/s" lab_1a.py The first lab in the BWSI CSS course. To complete this lab, fill out the variable on line 10 From 588328adf88080949e5d7ff61f2fdd79606d1529 Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 16:50:29 -0400 Subject: [PATCH 04/10] Update lab_1a.py fixing it up again --- labs/lab_1/lab_1a.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/labs/lab_1/lab_1a.py b/labs/lab_1/lab_1a.py index 8cf182b5..dace3c66 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -1,8 +1,10 @@ -"This is to simulate a change made on a robot: robot_speed = 5 # m/s" +"""" lab_1a.py 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 df26d59a2e79e83c31455069dd8ea8d8460c0db5 Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 16:54:44 -0400 Subject: [PATCH 05/10] 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 dace3c66..42441319 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 """ From 668245b16d3f84a52fb53f4aad1faab1612fba31 Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 18:09:16 -0400 Subject: [PATCH 06/10] Update lab_1a.py 8 ==> 5 --- 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 42441319..dace3c66 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 = 8 # m/s +This is to simulate a change made on a robot: robot_speed = 5 # m/s """ From 201a0f55fc4f2d3f3d4682dfb1488ff1ffa878b5 Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 18:09:51 -0400 Subject: [PATCH 07/10] 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 dace3c66..05da76fa 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 """ From 71f643b2c589e301079cecdafc7c5cbdc78296b6 Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 18:10:11 -0400 Subject: [PATCH 08/10] 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 dace3c66..42441319 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 """ From 2fd13d936007faeb192ee15e999e96663c1f42be Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 21:31:07 -0400 Subject: [PATCH 09/10] Update lab_1b.py santized the numbers --- labs/lab_1/lab_1b.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index e58dd957..068cb174 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -37,13 +37,29 @@ def simple_calculator(operation: str, num1: float, num2: float) -> float: else: raise ValueError("Invalid operation. Please choose from 'add', 'subtract', 'multiply', or 'divide'.") +def requested_sanitized_number(prompt: str) -> float: + """ + Function to request and sanitizie user input for the operation + + Returns: + float: The santized numeric input by the user + + """ + while True: + try: + number = float(input(prompt)) + return number + except ValueError: + print("Invalid input. Please enter a valid number.") + + 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 = requested_sanitized_number("Enter the first number: ") + num2 = requested_sanitized_number("Enter the secondabc number: ") operation = input("Enter the operation (add, subtract, multiply, divide): ").strip().lower() # Perform the calculation and display the result From 48585b07d5cf3af78cf993ed45b21405c2829f6a Mon Sep 17 00:00:00 2001 From: sylviey-yao Date: Wed, 25 Mar 2026 21:41:40 -0400 Subject: [PATCH 10/10] Update lab_1b.py --- labs/lab_1/lab_1b.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index 068cb174..3ff3f8e6 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -52,6 +52,20 @@ def requested_sanitized_number(prompt: str) -> float: except ValueError: print("Invalid input. Please enter a valid number.") +def requested_sanitized_operation(prompt: str) -> str: + """ + Function to request and sanitize user input for a wrong operation + + Returns: + str: the santinized string input by the user + + """ + while True: + operation = input(prompt).strip().lower() + if (operation == "multiply") or (operation == "add") or (operation == "subtract") or (operation == "divide"): + return operation + else: + print("Invalid input. Please enter a valid operation.") def main(): @@ -60,7 +74,7 @@ def main(): # Ask the user for sample input num1 = requested_sanitized_number("Enter the first number: ") num2 = requested_sanitized_number("Enter the secondabc number: ") - operation = input("Enter the operation (add, subtract, multiply, divide): ").strip().lower() + operation = requested_sanitized_operation("Enter the operation (add, subtract, multiply, divide): ") # Perform the calculation and display the result result = simple_calculator(operation, num1, num2)