From 4184921c48b6a8d110565ed1dde30ba51ef291a5 Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 12 Mar 2026 15:00:11 -0700 Subject: [PATCH 1/9] Update lab_1a.py 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 9d15ec837..96aae2022 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 = "Nishka Batra" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") From cdd47b39ef9ecd0251b205dc8cc3e2068b099690 Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 12 Mar 2026 15:03:40 -0700 Subject: [PATCH 2/9] Add cyber to lab_1a --- 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 96aae2022..e3e4077f2 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -11,6 +11,7 @@ def main(): name = "Nishka Batra" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") + print(f"I like cybersecurity!") if __name__ == "__main__": main() From d83748c896c825cc019e73bad11b5cfd81b64b56 Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 12 Mar 2026 15:23:17 -0700 Subject: [PATCH 3/9] Add robot speed comment --- 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 e3e4077f2..75d18783f 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 2c98b04d31e38f0b6935d400aac06415be6d3630 Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 12 Mar 2026 15:54:35 -0700 Subject: [PATCH 4/9] robot speed to 8 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 75d18783f..88a09440f 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 = 8 # m/s """ def main(): From fc6f0542a270367d55cea17b91d3f1ca956c9e9f Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 25 Jun 2026 03:24:24 -0700 Subject: [PATCH 5/9] Update1 Commit 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 88a09440f..99ea109f5 100644 --- a/labs/lab_1/lab_1a.py +++ b/labs/lab_1/lab_1a.py @@ -10,7 +10,7 @@ def main(): print("Hello World!") - name = "Nishka Batra" # TODO: Insert your name between the double quotes + name = "Nishka" # TODO: Insert your name between the double quotes print(f"{name}, Welcome to the CSS course!") print(f"I like cybersecurity!") From 3b7b7d2ecf2dd9624c84b0b65da8dd5710729b33 Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 25 Jun 2026 04:07:21 -0700 Subject: [PATCH 6/9] Add user input sanitation --- labs/lab_1/lab_1b.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/labs/lab_1/lab_1b.py b/labs/lab_1/lab_1b.py index e58dd9578..2892556db 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -37,13 +37,20 @@ 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.") + 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: ")) + operation = input("Enter the operation (add, subtract, multiply, divide): ").strip().lower() # Perform the calculation and display the result From 3f6c880430d429773b672d2f51e9803528596f4f Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 25 Jun 2026 04:15:39 -0700 Subject: [PATCH 7/9] upd --- 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 2892556db..dff1f559c 100644 --- a/labs/lab_1/lab_1b.py +++ b/labs/lab_1/lab_1b.py @@ -45,7 +45,7 @@ def request_sanitized_number(prompt: str) -> float: return number except ValueError: print("Invalid input.") - + def main(): print(f"===== Simple Calculator =====") From a598c6f54a3abfff2784d98eaed9c49b8261c4c8 Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 25 Jun 2026 04:28:24 -0700 Subject: [PATCH 8/9] new --- tests/test_calculator.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/test_calculator.py diff --git a/tests/test_calculator.py b/tests/test_calculator.py new file mode 100644 index 000000000..0172acc0c --- /dev/null +++ b/tests/test_calculator.py @@ -0,0 +1,9 @@ +import unittest +from labs.lab_1.lab_1b import simple_calculator + +class TestSanitize(unittest.TestCase): + def test_invalid_input(self): + self.assertEqual(simple_calculator("abc"), 0) # expecting 0 for bad input + +if __name__ == "__main__": + unittest.main() From f43db16d326d89db0348498cb2541126d40cea00 Mon Sep 17 00:00:00 2001 From: Nishka Batra Date: Thu, 25 Jun 2026 04:33:30 -0700 Subject: [PATCH 9/9] Create run_test.yml Add Github Actions Workflow --- .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 000000000..467613ceb --- /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