-
Notifications
You must be signed in to change notification settings - Fork 1
/
12-guss-the-number.py
55 lines (39 loc) · 1.13 KB
/
12-guss-the-number.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
45
46
47
48
49
50
51
52
53
54
55
# # # --------------Chapter -12 Calculator app in python------------------
# Create Function
def addition(nu1, nu2):
result = nu1 + nu2
print("{0}+{1}={2}".format(nu1, nu2, result))
def subtraction(nu1, nu2):
result = nu1 - nu2
print("{0}-{1}={2}".format(nu1, nu2, result))
def multiplication(nu1, nu2):
result = nu1 * nu2
print("{0}*{1}={2}".format(nu1, nu2, result))
def division(nu1, nu2):
if nu2 == 0.0:
print("Can't do dived by zero")
else:
result = nu1 / nu2
print("{0}/{1}={2}".format(nu1, nu2, result))
# # Display
print("What do you want to do?")
print("1 for addition")
print("2 for subtraction")
print("3 for multiplication")
print("4 for division")
# # User input - 2 Digit number
choice = input("Enter Your Choice : ")
# taking a 2 nuber as an input for user
nu1 = float(input("Enter Nuber One : "))
nu2 = float(input("Enter Nuber Two : "))
# # condition
if choice == '1':
addition(nu1, nu2)
elif choice == '2':
subtraction(nu1, nu2)
elif choice == '3':
multiplication(nu1, nu2)
elif choice == '4':
division(nu1, nu2)
else:
print("Invalid Choice")