0
Please Help Me To Fix This Calculator 😢 🙏🙏
My code is not working 😢 Sample input: 9+sin90° Expected Output: 10.0 https://code.sololearn.com/cKoDW6MZFPZn/?ref=app Help me to fix this 🙏🙏
3 Answers
+ 2
+ 1
MD. Ferdous Ibne Abu Bakar
Now enter any input and tell me if anything wrong
https://code.sololearn.com/c9cyja4No2Jp/?ref=app
0
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟
I have another problem in code↓↓↓
'''
SAMPLE INPUT (1):
cos0°+sin90°
EXPECTED OUTPUT:
2.0
SAMPLE INPUT (2):
sin90°/cos0°
EXPECTED OUTPUT:
1.0
'''
i = input()
import math
if 'sin' in i:
index = i.find('sin')
s = index + 3
d = i.find('°')
theta = eval(str((i[s : d])))
value = math.sin(math.radians(theta))
if 'cos' in i:
index = i.find('cos')
s = index + 3
d = i.find('°')
theta = eval(str((i[s : d])))
value = math.cos(math.radians(theta))
#replacing value after operand with calculated value
i = i.replace((i[(s-3):(d+1)]), str(value))
print(eval(i))