-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.py
37 lines (29 loc) · 978 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
31
32
33
34
35
36
37
print("_________________Welcome to calculator !_________________ ")
#Assigment operators used to simply assign data.
a = int (input ("Enter first number: ") )
b = int (input ("Enther secound number: "))
choice = int (input ("Enter the calculation you want to perform 1 for Addition, 2 for substraction, 3 for multiplication and 4 for division "))
#logical operator used to check if condition.
if choice <= 4:
#Arthematic operators used for calculations.
def case1 ():
print (a+b)
def case2 ():
print (a-b)
def case3 ():
print (a*b)
def case4 ():
print (a/b)
def switch_case(case):
#comparision operators to check conditions.
if(case == 1):
case1()
elif(case == 2):
case2()
elif(case == 3):
case3()
elif(case == 4):
case4()
switch_case(choice)
else:
print ("Enter number between 1 to 5... Please! ")