forked from waliullah9277/simple-project-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator_app.py
54 lines (43 loc) · 1.19 KB
/
calculator_app.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
# summatin function
def summatin(a,b):
r = a + b
return r
# subtraction function
def subtraction(a,b):
r = a - b
return r
# multiply function
def multiply(a,b):
r = a * b
return r
# division function
def division(a,b):
if b == 0:
return 'Error! Divide by zero is not allowed'
else:
r = a / b
return r
# calcultor function
def calcultor_app():
print('Welcome to the calcultor application')
print('Select the operator')
print('1. Summation')
print('2. Subtraction')
print('3. Multification')
print('4. Division')
choice = input('Enter choice (1/2/3/4): ')
if choice in ('1', '2', '3', '4'):
a = float(input('Enter a number: '))
b = float(input('Enter b number: '))
if choice == '1':
print("Summation is ", summatin(a,b))
elif choice == '2':
print("Subtraction is ", subtraction(a,b))
elif choice == '3':
print("Multification is ", multiply(a,b))
elif choice == '4':
print("Division is ", division(a,b))
else:
print('Invalid input! Please valid input is (1/2/3/4)')
# calculator functions call
calcultor_app()