forked from DSCSIT2020/Hacktoberfest-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.py
30 lines (27 loc) · 788 Bytes
/
Calculator.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
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):
return x/y
def power(x,y):
return pow(x,y)
print("\nOperation: ")
print("\n1. Addition \n2. Subtraction \n3. Multiplication \n4. Division \n5. Power")
choice=input("Enter your choice: ")
num1=int(input("Enter the first no: "))
num2=int(input("Enter the second no: "))
if choice=='1':
print(num1, "+", num2, "=", add(num1,num2))
elif choice=='2':
print(num1, "-", num2, "=", subtract(num1,num2))
elif choice=='3':
print(num1, "*", num2, "=", multiply(num1,num2))
elif choice=='4':
print(num1, "/", num2, "=", divide(num1,num2))
elif choice=='5':
print(num1, "^", num2, "=", power(num1,num2))
else:
print("Please choose the correct option.")