-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator
97 lines (64 loc) · 1.98 KB
/
calculator
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import math
def add( a,b ):
return a + b
def sub( a, b ):
return a - b
def mul( a, b ):
return a * b
def div( a, b ):
return a / b
def mod ( a, b):
return a % b
def cinterest ( p, r, n, t ):
return p * m.pow((1 + r/n), n * t)
def sinterest ( p, t, r ):
return ( p * t * r )/100
print("select operation. ")
print(" 1.Add")
print(" 2.Subtract")
print(" 3.Multiply")
print(" 4.Divide")
print(" 5.cinterest")
print(" 6.sinterest")
while True :
choice = input("Enter choice(1/2/3/4/5/6): ")
if choice in ('1', '2', '3', '4', ):
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == '1':
res = num1 + num2
print("Result = ", res)
elif choice == '2':
res = num1 - num2
print("Result = ", res)
elif choice == '3':
res = num1 * num2
print("Result = ", res)
elif choice == '4':
res = num1 / num2
print("Result", res)
elif choice in ('5', '6',):
p = float(input("Enter principal: "))
t = float(input("Enter the time in years: "))
r = float(input("Enter the rate of interest: "))
if choice == '1':
res = num1 + num2
print("Result = ", res)
elif choice == '2':
res = num1 - num2
print("Result = ", res)
elif choice == '3':
res = num1 * num2
print("Result = ", res)
elif choice == '4':
res = num1 / num2
print("Result", res)
elif choice == '5':
res = p * (math.pow((1 + r / 100), t))
print("Result = ", res)
elif choice == '6':
res = p * t * r
print("Result", res)
break
else:
print("Invalid Input")