Skip to content

Commit ed59edb

Browse files
author
shreydan
committed
updated calculator.py
1 parent d81eb50 commit ed59edb

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

calculator.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* : multiplication
1111
/ : division
1212
% : percentage
13-
sin: sine(rad)
14-
cos: cosine(rad)
15-
tan: tangent(rad)
16-
sqrt: square_root(n)
13+
sine: sin(rad)
14+
cosine: cos(rad)
15+
tangent: tan(rad)
16+
square root: sqrt(n)
1717
pi: 3.141......
1818
"""
1919

@@ -23,12 +23,12 @@ def main():
2323

2424
def calc(k):
2525

26-
functions = ['sin','cos','tan','sqrt','pi']
26+
functions = ['sin', 'cos', 'tan', 'sqrt', 'pi']
2727

2828
for i in functions:
2929
if i in k.lower():
3030
withmath = 'math.' + i
31-
k = k.replace(i,withmath)
31+
k = k.replace(i, withmath)
3232

3333
try:
3434
k = eval(k)
@@ -46,11 +46,11 @@ def calc(k):
4646

4747
k = input("\nWhat is ")
4848

49-
k = k.replace(' ','')
50-
k = k.replace('^','**')
51-
k = k.replace('=','')
52-
k = k.replace('?','')
53-
k = k.replace('%','/100')
49+
k = k.replace(' ', '')
50+
k = k.replace('^',' **')
51+
k = k.replace('=', '')
52+
k = k.replace('?', '')
53+
k = k.replace('%', '/100')
5454

5555
print ("\n" + str(calc(k)))
5656

0 commit comments

Comments
 (0)