logicalboy 发表于 2020-4-12 15:43:31

python求助

已知三角形的两边长及其夹角,求第三边长。提示:首先需要导入math库,格式为:import math。然后需要注意cos括号里面的数值默认是需要输入的为弧度,需要你把角度转换为弧度才可以做出来正确的结果(你可以尝试使用百度搜素一下python中cos的使用方法。)


Hello. 发表于 2020-4-12 15:49:06

import math
x = input('输入两边长其夹角:')
a,b,theta = map(float,x.split())
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta*math.pi/180))
print('c=',c)
有用设置最佳
页: [1]
查看完整版本: python求助