-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathfuncalc.py
More file actions
54 lines (39 loc) · 1006 Bytes
/
funcalc.py
File metadata and controls
54 lines (39 loc) · 1006 Bytes
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
# calculator using functions
def add(num1, num2):
ans = num1 + num2
return ans
def sub(num1, num2):
ans = num1 - num2
return ans
def mult(num1, num2):
ans = num1 * num2
return ans
def dev(num1, num2):
ans = num1 / num2
return ans
def pow(num1, num2):
ans = num1 ** num2
return ans
""" end of functions
the so called main"""
rep = 'yes'
while rep == 'yes':
num1 = float(input('Enter number 1 : '))
print('Enter one of the following operator :\n+ - * / ^ ')
op = input('Operator : ')
num2 = float(input('Enter number 2 : '))
if op == '+':
ans = add(num1, num2)
elif op == '-':
ans = sub(num1, num2)
elif op == '*':
ans = mult(num1, num2)
elif op == '/':
ans = dev(num1, num2)
elif op == '^':
ans = pow(num1, num2)
else:
print('Invalid input .....Exiting ')
exit()
print(num1, op, num2, '=', ans)
rep = input('Do you want to countinue(yes/no) ? :')