-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek1_assignment.py
More file actions
27 lines (25 loc) · 836 Bytes
/
week1_assignment.py
File metadata and controls
27 lines (25 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Basic Calculator
print("Welcome! Happy MATHEMATICS")
# Get user input
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
operation = input("Enter the operation (+, -, *, /): ")
# Perform the calculation
result = 0
if operation == '+':
result = num1 + num2
print(f"{num1} + {num2} = {result}")
elif operation == '-':
result = num1 - num2
print(f"{num1} - {num2} = {result}")
elif operation == '*':
result = num1 * num2
print(f"{num1} * {num2} = {result}")
elif operation == '/':
if num2 != 0: # Check for division by zero
result = num1 / num2
print(f"{num1} / {num2} = {result}")
else:
print("Error: Division by zero is not allowed!")
else:
print("Invalid operation! Please enter one of: +, -, *, /")