-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
44 lines (33 loc) · 910 Bytes
/
main.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def add(x, y):
return x + y
def subtract(x, y)
return x - y
def multiply(x, y)
return x * y
def divide(x, y)
if y == 0:
print("Cannot divide by zero!")
return x / y
print("Simple Math Application")
print("-----------------------")
while True:
num1 = input("Enter first number: ")
num1 = int(num1)
operator = input("Enter operator (+, -, *, /): ")
num2 = input("Enter second number: ")
num2 = int(num2)
if operator == "+":
result = add(num1, num2)
else if operator == "-":
result = subtract(num1, num2)
else if operator == "*":
result = multiply(num1, num2)
else if operator == "/":
result = divide(num1, num2)
else:
print("Invalid operator!")
print(f"The result is: {result}")
again = input("Do you want to perform another calculation? (y/n): ")
if again.lower() != "y":
break
print("Thank you for using the Simple Math Application!")