-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScalc.py
More file actions
22 lines (22 loc) · 761 Bytes
/
Copy pathScalc.py
File metadata and controls
22 lines (22 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from sympy import oo as Infinity
from sympy import nan, ln, sin, cos, tan, sec, csc, cot, asin, acos, atan, asec, acsc, acot, sinh, cosh, tanh, sech, csch, coth
import sympy as s
pi = s.pi
e = s.E
log = ln
cosec, acosec, cosech = csc, acsc, csch
del s
def solve(expr):
if expr=='Nikhil Nayak(9663)':
return ('Hey There Creator!, Summing Up Your Wish!')
try:
res = eval(expr)
return str(res).replace('pi', 'π').replace('zoo', 'Infinity').replace('csc', 'cosec').replace('**', '^')
except ZeroDivisionError:
if eval(expr.split('/')[0])==0:
return nan
elif eval(expr.split('/')[0])<0:
return -Infinity
else:
return Infinity
print(solve('-1/0'))