From b7a0227264f906991617f7392abd7d4c337dabe4 Mon Sep 17 00:00:00 2001 From: sandyaking Date: Sun, 8 Mar 2026 17:37:23 -0400 Subject: [PATCH 1/4] 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..b768defb 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 = "Charlotte King" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") From 25d711a9600ccb64d5b201aaf6311f2f65777116 Mon Sep 17 00:00:00 2001 From: sandyaking Date: Sun, 8 Mar 2026 17:51:47 -0400 Subject: [PATCH 2/4] Update lab_1a.py added comment explaining purpose of variable --- labs/lab_1/lab_1a.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/labs/lab_1/lab_1a.py b/labs/lab_1/lab_1a.py index b768defb..92dca82e 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -3,6 +3,8 @@ 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 d602c60d0d2e4fae6950e6c6a23b68f29fbbc884 Mon Sep 17 00:00:00 2001 From: sandyaking Date: Sun, 8 Mar 2026 18:03:08 -0400 Subject: [PATCH 3/4] 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 92dca82e..be045935 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -4,7 +4,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 stimulate a change made on a robot: robot_speed = 3 # m/s """ def main(): From b86625c9ea2240bcbbedc4398faa5b34527601c6 Mon Sep 17 00:00:00 2001 From: sandyaking Date: Sun, 8 Mar 2026 18:25:34 -0400 Subject: [PATCH 4/4] add user input sanitization --- labs/lab_1/lab_1b.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index e58dd957..5a28844a 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -37,13 +37,23 @@ def simple_calculator(operation: str, num1: float, num2: float) -> float: else: raise ValueError("Invalid operation. Please choose from 'add', 'subtract', 'multiply', or 'divide'.") +def request_sanitized_number(prompt: str) -> float: + """ + Function that takes in a prompt and returns a sanitized number. + """ + while True: + try: + return float(input(prompt)) + 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 = request_sanitized_number("Enter the first number: ") + num2 = request_sanitized_number("Enter the second number: ") operation = input("Enter the operation (add, subtract, multiply, divide): ").strip().lower() # Perform the calculation and display the result