From 4b9576521072f75b1eb89c966f2f25e733a598b1 Mon Sep 17 00:00:00 2001 From: Shravan380 Date: Tue, 17 Mar 2026 20:05:37 -0400 Subject: [PATCH 1/8] Update lab_1a.py Wrote my name in the name 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 9d15ec83..e4ce95d7 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 = "Shravan Aadithya" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") From b94747a9a4d1c7ead7e4279897551438cc3efdb4 Mon Sep 17 00:00:00 2001 From: Shravan380 Date: Tue, 17 Mar 2026 20:11:56 -0400 Subject: [PATCH 2/8] Update lab_1a.py Added my introduction to a print statement. --- 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 e4ce95d7..b8131bf2 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -11,6 +11,6 @@ def main(): name = "Shravan Aadithya" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") - + print("Hi all! I'm Shravan, and I'm a sophomore from Virginia! I am in TSA, and I have been in a height growth competition.") if __name__ == "__main__": main() From 105576b580830a5129ff366d956c2131f5b17cae Mon Sep 17 00:00:00 2001 From: Shravan380 Date: Tue, 17 Mar 2026 20:19:00 -0400 Subject: [PATCH 3/8] Add comment about robot speed variable Added a comment explaining the purpose of the variable. --- 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 b8131bf2..f79d20b3 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 90c2b9d7d70c8a8244d24362737f9d2ed5df1d53 Mon Sep 17 00:00:00 2001 From: Shravan380 Date: Tue, 17 Mar 2026 20:23:54 -0400 Subject: [PATCH 4/8] Update robot speed Updated robot speed 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 f79d20b3..45893d05 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 c8e293b2362d64cae5b7709928bb1543b8a434d4 Mon Sep 17 00:00:00 2001 From: Shravan380 Date: Tue, 17 Mar 2026 20:25:28 -0400 Subject: [PATCH 5/8] Update robot speed var Updated robot speed 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 f79d20b3..45c973b4 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 91f08371da1f527c776b3d4898efe997b0c097e1 Mon Sep 17 00:00:00 2001 From: Shravan380 Date: Wed, 18 Mar 2026 06:29:50 -0400 Subject: [PATCH 6/8] Fixed input value type mismatch I added a function where the num1 and num2 will keep asking the user for a valid number if the user enters something else. --- 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..b6377f0c 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -37,13 +37,21 @@ 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: + 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 From ab867e95e8ac3dbeb7c08f37958a1753b64563cf Mon Sep 17 00:00:00 2001 From: Shravan380 Date: Tue, 24 Mar 2026 06:34:33 -0400 Subject: [PATCH 7/8] Clean Operation Added function to program to ensure that the operation entered by the user is valid; otherwise, it will keep asking the user for a valid operation. --- labs/lab_1/lab_1b.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index b6377f0c..f148691b 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -45,6 +45,10 @@ def request_sanitized_number(prompt: str) -> float: except ValueError: print("Invalid input. Please enter a valid number.") +def clean_operation(operation: str): + while(operation != "add" and operation != "subtract" and operation != "multiply" and operation != "divide"): + operation = input("Enter a valid operation (add, subtract, multiply, divide): ").strip().lower() + return operation def main(): print(f"===== Simple Calculator =====") @@ -52,7 +56,7 @@ def main(): # Ask the user for sample input 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() + operation = clean_operation(input("Enter the operation (add, subtract, multiply, divide): ").strip().lower()) # Perform the calculation and display the result result = simple_calculator(operation, num1, num2) From ebe749c80172efcc5e7badd0460a2e7ffdd18701 Mon Sep 17 00:00:00 2001 From: Shravan380 Date: Tue, 24 Mar 2026 06:57:11 -0400 Subject: [PATCH 8/8] Added another test case Added another test case --- .github/workflows/run_test.yml | 32 ++++++++++++++++++++++++++++++++ tests/tests_1b.py | 1 + 2 files changed, 33 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 diff --git a/tests/tests_1b.py b/tests/tests_1b.py index be6b822d..fbddc186 100644 --- a/tests/tests_1b.py +++ b/tests/tests_1b.py @@ -26,6 +26,7 @@ def test_division(): assert simple_calculator("divide", 6, 3) == 2 # Test for positive numbers assert simple_calculator("divide", -4, 2) == -2 # Test for negative and positive number assert simple_calculator("divide", 5, 2) == 2.5 # Test for division resulting in float + assert simple_calculator("divide", 0 , 1) == 0 #Test for dividng 0 by num def test_division_by_zero(): with pytest.raises(ValueError, match="Cannot divide by zero."):