Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions labs/lab_1/lab_1a.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
"""
lab_1a.py

This is to simulate a change made on a robot: 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 = "Kishan Paschapur" # TODO: Insert your name between the double quotes

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

if __name__ == "__main__":
main()
# --- IGNORE ---
24 changes: 21 additions & 3 deletions labs/lab_1/lab_1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,27 @@ 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:
num1 = float(input("Enter the first number: "))
break
except ValueError:
print("That's not a number. Please try again.")

while True:
try:
num2 = float(input("Enter the second number: "))
break
except ValueError:
print("That's not a number. Please try again.")

# Ask the user for the operation
while True:
operation = input("Enter the operation (add, subtract, multiply, divide): ").lower()
if operation == "add" or operation == "subtract" or operation == "multiply" or operation == "divide":
break
else:
print("Invalid operation. Please choose from 'add', 'subtract', 'multiply', or 'divide'.")

# Perform the calculation and display the result
result = simple_calculator(operation, num1, num2)
Expand Down