Skip to content
32 changes: 32 additions & 0 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion labs/lab_1/lab_1a.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""
lab_1a.py

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

def main():
print("Hello World!")

name = "" # TODO: Insert your name between the double quotes
name = "Aayan Majid" # TODO: Insert your name between the double quotes

print(f"{name}, Welcome to the CSS course!")

Expand Down
9 changes: 9 additions & 0 deletions labs/lab_1/lab_1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ def simple_calculator(operation: str, num1: float, num2: float) -> float:
raise ValueError("Cannot divide by zero.")
else:
raise ValueError("Invalid operation. Please choose from 'add', 'subtract', 'multiply', or 'divide'.")

def sanitized_num(prompt: str) -> float:

try:
number = float(input(prompt))
return number

except ValueError:
print("invalid num, try again.")

def main():

Expand Down