From a122928af9b4164ce0cb4a17e476528028cd65cd Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Thu, 5 Feb 2026 17:31:41 -0500 Subject: [PATCH 01/18] Add name to 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..9306b5db 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 = "Isha Goel" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") From 4f04ba5200399146493d332220aadbfaf8712e6c Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Thu, 5 Feb 2026 17:36:48 -0500 Subject: [PATCH 02/18] Update lab_1a.py --- 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 9306b5db..dd64e653 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -7,6 +7,7 @@ def main(): print("Hello World!") + print("This is my first lab in the BWSI CSS course. I love aircraft and I hope to learn a lot!") name = "Isha Goel" # TODO: Insert your name between the double quotes From ea7d1c834a9c87efb5e3d55657c475bdf11b4391 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Thu, 5 Feb 2026 17:38:30 -0500 Subject: [PATCH 03/18] Added description 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 dd64e653..51270453 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -7,7 +7,7 @@ def main(): print("Hello World!") - print("This is my first lab in the BWSI CSS course. I love aircraft and I hope to learn a lot!") + print("This is my first lab in the BWSI CSS course. I love aircraft and I hope to learn a lot.") name = "Isha Goel" # TODO: Insert your name between the double quotes From a2abc571689bf73dce3910ec95874df21927537c Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 9 Feb 2026 22:33:01 -0500 Subject: [PATCH 04/18] Add comment for robot speed variable Added a comment explaining the purpose of the 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 51270453..be9cbc41 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 70cc2c0c010dd6fc444951382524899f6b02eb96 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 9 Feb 2026 22:33:52 -0500 Subject: [PATCH 05/18] Change 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 be9cbc41..5acc2c20 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 simulate a change made on a robot: robot_speed = 3 # m/s """ def main(): From f2e77af45afbbc4f89585359fffafee9641d75c7 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 9 Feb 2026 22:40:08 -0500 Subject: [PATCH 06/18] Update lab_1a.py 5 to 3 From 943639c467a6aba6d1397318d17095236f2eaf45 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 9 Feb 2026 22:40:29 -0500 Subject: [PATCH 07/18] 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 5acc2c20..89118230 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 = 3 # m/s +This is to simulate a change made on a robot: robot_speed = 8 # m/s """ def main(): From 2ea261f4bb48c9c5fe75d835902bb75e12e004f7 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 9 Feb 2026 22:41:49 -0500 Subject: [PATCH 08/18] Change 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 89118230..5acc2c20 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 = 8 # m/s +This is to simulate a change made on a robot: robot_speed = 3 # m/s """ def main(): From 900875418d2c076c6cef9a90349df15781e1409b Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 9 Feb 2026 22:42:56 -0500 Subject: [PATCH 09/18] 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 89118230..ad5e0b69 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 = 8 # m/s +This is to simulate a change made on a robot: robot_speed = 8 # m/s """ def main(): From cc75bbf07e29943fc14293fabbd05769b3520210 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Tue, 10 Feb 2026 17:02:37 -0500 Subject: [PATCH 10/18] Added function to calculator --- labs/lab_1/lab_1b.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index e58dd957..470abd3c 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -37,13 +37,25 @@ 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 prompts the user for a number and ensures that the input is valid. + + Returns: + float: The sanitized number input by the user. + """ + 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 From 51b98e8f286656451b1870e52a16f78cfd590a68 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Tue, 10 Feb 2026 17:24:44 -0500 Subject: [PATCH 11/18] add function to calculator --- labs/lab_1/lab_1b.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index e58dd957..8f842609 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -37,13 +37,26 @@ 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 number input by the user. + """ + + 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 From e8301651577bebe229f708b826e38bccf8eb478d Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 16 Mar 2026 15:04:03 -0400 Subject: [PATCH 12/18] added unit tests for simple _calculator --- .github/workflows/run_test.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/run_test.yml diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml new file mode 100644 index 00000000..c45bcbfc --- /dev/null +++ b/.github/workflows/run_test.yml @@ -0,0 +1,32 @@ +name: simple_calculator unit test + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with Ruff + run: | + pip install ruff + ruff --format=github --target-version=py310 . + continue-on-error: true + - name: Test with pytest + run: | + coverage run -m pytest tests/tests_1b.py -v -s + - name: Generate Coverage Report + run: | + coverage report -m \ No newline at end of file From 67cf044c8327f73b298215c3fd310c456648e888 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 16 Mar 2026 15:25:01 -0400 Subject: [PATCH 13/18] fixed ruff linter --- labs/lab_1/lab_1b.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index 8f842609..34b5ba3a 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -52,7 +52,7 @@ def request_sanitized_number(prompt: str) -> float: print("Invalid input. Please enter a valid number.") def main(): - print(f"===== Simple Calculator =====") + print("===== Simple Calculator =====") # Ask the user for sample input num1 = request_sanitized_number("Enter the first number: ") From ee7ce6eeaa6eefaf08dfc04d995fd2f274d6aa71 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 16 Mar 2026 16:47:00 -0400 Subject: [PATCH 14/18] Update lab_1b.py --- labs/lab_1/lab_1b.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index 34b5ba3a..8cdac37e 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -52,7 +52,7 @@ def request_sanitized_number(prompt: str) -> float: print("Invalid input. Please enter a valid number.") def main(): - print("===== Simple Calculator =====") + print("Simple Calculator ") # Ask the user for sample input num1 = request_sanitized_number("Enter the first number: ") From 016bfb699d2ecec1dc92d78f1b131f2fb31692e1 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 16 Mar 2026 17:00:25 -0400 Subject: [PATCH 15/18] Final Cleanup --- labs/lab_1/lab_1b.py | 63 +++++++++++--------------------------------- 1 file changed, 15 insertions(+), 48 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index 53b5b1ba..9c8657f4 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -1,28 +1,5 @@ -""" -lab_1b.py - -This is a script that implements a simple calculator. It takes two numbers and an operation, -then performs the operation and returns the result. - -The script asks the user to input the numbers and the operation to be performed, -and prints the result to the terminal window. - -""" def simple_calculator(operation: str, num1: float, num2: float) -> float: - """ - Function that takes in two numbers and an operation (add, subtract, multiply, divide), - then performs the operation on the two numbers and returns the result. - - Args: - operation (str): The operation to perform ("add", "subtract", "multiply", "divide"). - num1 (float): The first number. - num2 (float): The second number. - - Returns: - float: The result of the operation. - """ - if operation == "add": return num1 + num2 elif operation == "subtract": @@ -30,46 +7,36 @@ def simple_calculator(operation: str, num1: float, num2: float) -> float: elif operation == "multiply": return num1 * num2 elif operation == "divide": - if num2 != 0: - return num1 / num2 - else: + if num2 == 0: raise ValueError("Cannot divide by zero.") + return num1 / num2 else: - raise ValueError("Invalid operation. Please choose from 'add', 'subtract', 'multiply', or 'divide'.") + raise ValueError("Invalid operation.") def request_sanitized_number(prompt: str) -> float: - """ -tests/simple_calculator - Function to request and sanitize user input for the operation - - Returns: - float: The sanitized number input by the user. - """ - - Function that prompts the user for a number and ensures that the input is valid. - - Returns: - float: The sanitized number input by the user. - """ -main while True: try: return float(input(prompt)) except ValueError: print("Invalid input. Please enter a valid number.") +<<<<<<< Updated upstream def main(): print("===== Simple Calculator =====") +======= +>>>>>>> Stashed changes - # Ask the user for sample input +def main(): + print("Simple Calculator") 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 - result = simple_calculator(operation, num1, num2) - print(f"The result of {operation}ing {num1} and {num2} is: {result}") + operation = input("Enter the operation (add, subtract, multiply, divide): ") + try: + result = simple_calculator(operation, num1, num2) + print(f"The result of {operation}ing {num1} and {num2} is: {result}") + except ValueError as e: + print(e) if __name__ == "__main__": - main() + main() \ No newline at end of file From ea23ceb68e4b2a8ef6d4d6de7d1ed0b16d9c3d12 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 16 Mar 2026 17:11:26 -0400 Subject: [PATCH 16/18] Fixed final syntax error --- labs/lab_1/lab_1b.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index 9c8657f4..7a990df5 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -19,13 +19,7 @@ def request_sanitized_number(prompt: str) -> float: return float(input(prompt)) except ValueError: print("Invalid input. Please enter a valid number.") -<<<<<<< Updated upstream -def main(): - - print("===== Simple Calculator =====") -======= ->>>>>>> Stashed changes - + def main(): print("Simple Calculator") num1 = request_sanitized_number("Enter the first number: ") From fc6f468feba2f2b28e5cbec77bae37b189b636d1 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 16 Mar 2026 17:13:42 -0400 Subject: [PATCH 17/18] Match exact error message --- labs/lab_1/lab_1b.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index 7a990df5..8119772d 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -11,7 +11,7 @@ def simple_calculator(operation: str, num1: float, num2: float) -> float: raise ValueError("Cannot divide by zero.") return num1 / num2 else: - raise ValueError("Invalid operation.") + raise ValueError("Invalid operation. Please choose from 'add', 'subtract', 'multiply', or 'divide'.") def request_sanitized_number(prompt: str) -> float: while True: @@ -19,7 +19,7 @@ def request_sanitized_number(prompt: str) -> float: return float(input(prompt)) except ValueError: print("Invalid input. Please enter a valid number.") - + def main(): print("Simple Calculator") num1 = request_sanitized_number("Enter the first number: ") From e75d19c5bbae665afd2c8c1cc303964292b05f28 Mon Sep 17 00:00:00 2001 From: IshaG1234 Date: Mon, 16 Mar 2026 17:31:11 -0400 Subject: [PATCH 18/18] add automation --- .github/workflows/run_test.yml | 63 +++++++++++++++++----------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index c45bcbfc..56a7166f 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -1,32 +1,33 @@ name: simple_calculator unit test - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.10"] - - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with Ruff - run: | - pip install ruff - ruff --format=github --target-version=py310 . - continue-on-error: true - - name: Test with pytest - run: | - coverage run -m pytest tests/tests_1b.py -v -s - - name: Generate Coverage Report - run: | - coverage report -m \ No newline at end of file + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with Ruff + run: | + pip install ruff + ruff --format=github --target-version=py310 . + continue-on-error: true + - name: Test with pytest + run: | + pytest + - name: Generate Coverage Report + run: | + pip install pytest-cov + pytest --cov=labs/lab_1 --cov-report=term-missing \ No newline at end of file