From 074a359635978a9d669f5ef5756e3776df7cee29 Mon Sep 17 00:00:00 2001 From: Arnab Date: Mon, 16 Mar 2026 19:32:20 -0400 Subject: [PATCH 1/5] Update lab_1a.py added my name --- 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..98b9fed1 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 = "Arnab" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") From 0f03e6b075a5a87838503a1fa9dca0fdf038fe1d Mon Sep 17 00:00:00 2001 From: ad1719 Date: Tue, 17 Mar 2026 19:40:55 -0400 Subject: [PATCH 2/5] Add comment about robot speed variable Added a comment explaining the purpose of the variable --- 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 98b9fed1..d615f7aa 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -1,6 +1,6 @@ """ lab_1a.py - +This is to simulate a change made on a robot: robot_speed = 5 # m/s 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. """ From 2f602db2b0abd1621561cebf82ef41f790ee1ac3 Mon Sep 17 00:00:00 2001 From: ad1719 Date: Tue, 17 Mar 2026 19:45:24 -0400 Subject: [PATCH 3/5] Change robot speed from 5 m/s to 3 m/s Lowered Robot Speed --- 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 d615f7aa..78196403 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -1,6 +1,6 @@ """ lab_1a.py -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 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. """ From 82f92639cfc1e15a41dcb57f42dd50d4d17c6f75 Mon Sep 17 00:00:00 2001 From: Arnab Date: Tue, 17 Mar 2026 19:54:28 -0400 Subject: [PATCH 4/5] 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 d615f7aa..e0faeeda 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -1,6 +1,6 @@ """ lab_1a.py -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 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. """ From b74764df3aa146bad7cd157bc75223677b78a50c Mon Sep 17 00:00:00 2001 From: Arnab Date: Wed, 18 Mar 2026 19:18:00 -0400 Subject: [PATCH 5/5] add input sanitization --- labs/lab_1/lab_1b.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index e58dd957..f032c7c2 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -37,13 +37,28 @@ 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 to request and sanitize user input for the operation. + + Returns: + float: The sanitized 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 = 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