Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a122928
Add name to lab_1a.py
IshaG1234 Feb 5, 2026
4f04ba5
Update lab_1a.py
IshaG1234 Feb 5, 2026
ea7d1c8
Added description lab_1a.py
IshaG1234 Feb 5, 2026
a2abc57
Add comment for robot speed variable
IshaG1234 Feb 10, 2026
70cc2c0
Change robot speed from 5 m/s to 3 m/s
IshaG1234 Feb 10, 2026
f2e77af
Update lab_1a.py 5 to 3
IshaG1234 Feb 10, 2026
943639c
Update lab_1a.py
IshaG1234 Feb 10, 2026
c693ac9
Merge branch 'main' of https://github.com/IshaG1234/bwsi-css-labs
IshaG1234 Feb 10, 2026
2ea261f
Change robot speed from 5 m/s to 3 m/s
IshaG1234 Feb 10, 2026
9008754
Update lab_1a.py
IshaG1234 Feb 10, 2026
5d6628e
Merge branch 'main' of https://github.com/IshaG1234/bwsi-css-labs
IshaG1234 Feb 10, 2026
cc75bbf
Added function to calculator
IshaG1234 Feb 10, 2026
51b98e8
add function to calculator
IshaG1234 Feb 10, 2026
e452e6a
Merge pull request #2 from IshaG1234/fix/sanitize
IshaG1234 Feb 10, 2026
e830165
added unit tests for simple _calculator
IshaG1234 Mar 16, 2026
67cf044
fixed ruff linter
IshaG1234 Mar 16, 2026
ef7e8e6
Merge branch 'main' into tests/simple_calculator
IshaG1234 Mar 16, 2026
1361289
Merge pull request #3 from IshaG1234/tests/simple_calculator
IshaG1234 Mar 16, 2026
ee7ce6e
Update lab_1b.py
IshaG1234 Mar 16, 2026
dd890fd
Merge branch 'tests/simple_calculator' of https://github.com/IshaG123…
IshaG1234 Mar 16, 2026
016bfb6
Final Cleanup
IshaG1234 Mar 16, 2026
ea23ceb
Fixed final syntax error
IshaG1234 Mar 16, 2026
fc6f468
Match exact error message
IshaG1234 Mar 16, 2026
e75d19c
add automation
IshaG1234 Mar 16, 2026
e5a6d10
Merge branch 'main' into tests/simple_calculator
IshaG1234 Mar 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +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: |
pytest
- name: Generate Coverage Report
run: |
pip install pytest-cov
pytest --cov=labs/lab_1 --cov-report=term-missing
5 changes: 4 additions & 1 deletion labs/lab_1/lab_1a.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

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
"""

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 = "" # 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!")

Expand Down
57 changes: 22 additions & 35 deletions labs/lab_1/lab_1b.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,42 @@
"""
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":
return num1 - num2
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'.")

def request_sanitized_number(prompt: str) -> float:
while True:
try:
return float(input(prompt))
except ValueError:
print("Invalid input. Please enter a valid number.")
tests/simple_calculator
def main():

print(f"===== Simple Calculator =====")
print("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()
main

# 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}")
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): ")

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()