Python三角函数

Python三角函数:

函数:

'''

math.sin(x)
返回的x弧度的正弦值。
math.asin(x)
返回x的反正弦弧度值。

math.cos(x)
返回x的弧度的余弦值。
math.acos(x)
返回x的反余弦弧度值。

math.tan(x)
返回x弧度的正切值。
math.atan(x)
返回x的反正切弧度值。

math.degrees(x)
将弧度转换为角度,如degrees(math.pi/2) , 返回90.0
math.radians(x)
将角度转换为弧度
math.hypot(x, y)
返回 sqrt(x*x + y*y) 的值。
'''

程序:

import math

# π/2 的正弦值
print(math.sin(math.pi/2))
# 1.0

#  1 的反正弦值
print(math.asin(1))
# 1.5707963267948966    π/2

# π 的余弦值
print(math.cos(math.pi))
# -1.0

#  -1 的反余弦值
print(math.acos(-1))
# 3.141592653589793

# 四分之三 π 的正切值
print(math.tan(math.pi*3/4))
# -1.0000000000000002

# 使用 math.degrees(x) 函数查看 四分之一 π 的角度
print(math.degrees(math.pi/4))
# 45.0

# 使用 math.radians(x) 函数查看 135° 对应的弧度制
print(math.radians(135))
# 2.356194490192345
print(math.pi*3/4)
# 2.356194490192345

# math.hypot(x, y) 查看 sqrt(x*x + y*y) 的值
print(math.hypot(3,4))
# 5.0
print(math.hypot(6,8))
# 10.0

print(math.sqrt(6*6 + 8*8))
# 10.0

2020-02-06

原文地址:https://www.cnblogs.com/hany-postq473111315/p/12269772.html