Python三角函数计算

根据下面公式计算并输出x的值,a和b的值由用户输入,括号里的数字是角度值,要求圆周率的值使用数学常数math.pi,开平方使用math库中开平方函数,三角函数的值用math库中的函数进行计算。

img

import math

a = int(input(">>>"))
b = int(input(">>>"))

d = math.radians(60)
x = (-b + math.sqrt(2 *a *math.sin(d) *math.cos(d))) / (2 * a)

print(x)

'''--result
>>>2
>>>5
-0.9209814967618768
'''


import math

a = eval(input())
b = eval(input())
x = (-b+(2*a*math.sin(math.radians(60))*math.cos(math.radians(60)))**(1/2))/(2*a)
print(x)