Python 三角形第三边

已知三角形的两边及夹角,求第三边
这里我们用三角形的余弦定理

在这里插入图片描述

#已知三角形的两边及夹角,求第三边
import math
x=input('输入两边及夹角以逗号分隔:')
a,b,j=eval(x)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
c=math.sqrt(a**2+b**2-math.cos(j*math.pi/180)*2*a*b)
print("c={:.2f}".format(c))

猜你喜欢

转载自blog.csdn.net/weixin_50925658/article/details/113722196