-
Notifications
You must be signed in to change notification settings - Fork 0
/
SolAssignment1.py
44 lines (37 loc) · 1.08 KB
/
SolAssignment1.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 Multiply(x,y):
z = x * y
print("Answer: ",z)
def Divide(x,y):
if y != 0:
z = x / y
print("Answer: ",z)
else:
print("Division by 0 is not defined")
def Add(x,y):
z = x + y
print("Answer: ",z)
def Subtract(x,y):
z = x - y
print("Answer: ",z)
ch = "y"
while ch == "Y" or ch == "y":
operation = input("What would you like to do?\n1.Add\n2.Subtract\n3.Multiply\n4.Divide ")
if operation == "1":
x = float(input("First number: "))
y = float(input("Second number: "))
Add(x,y)
elif operation == "2":
x = float(input("First number: "))
y = float(input("Second number: "))
Subtract(x,y)
elif operation == "3":
x = float(input("First number: "))
y = float(input("Second number: "))
Multiply(x,y)
elif operation == "4":
x = float(input("First number: "))
y = float(input("Second number: "))
Divide(x,y)
else:
print("Wrong Input")
ch = input("Would you like to continue ? y/n")