Skip to content
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,14 +3,17 @@

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

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

print(f"{name}, Welcome to the CSS course!")
print("Hey all! My name's Neil and I'm a junior in Boston, MA. Outside of STEM, I loving playing and watching my favorite sports: football and basketball.")

if __name__ == "__main__":
main()
22 changes: 15 additions & 7 deletions labs/lab_1/lab_1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +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 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()
while True:
try:
operation = input("Enter operation: ").lower()

num1 = float(input("Enter 1st num: "))
num2 = float(input("Enter 2nd num: "))

result = simple_calculator(operation, num1, num2)
print("Result:", result)
break

# 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}")
except ValueError as e:
print("Error:", e)
print("Try again\n")


if __name__ == "__main__":
Expand Down