Python中的度数()和弧度()
degress() 和 radians() 是Python 3 和Python 2 的数学模块中指定的方法。
通常需要处理将弧度转换为度数的数学计算,反之亦然,尤其是在几何领域。 Python提供了内置方法来处理此功能。本文讨论了这两个功能。
此函数接受“度”作为输入并将其转换为等效的弧度。
Syntax : radians(deg)
Parameters :
deg : The degrees value that one needs to convert into radians
Returns : This function returns the floating point radians equivalent of argument.
Computational Equivalent : 1 Radians = 180/pi Degrees.
代码#1:演示弧度()
# Python code to demonstrate
# working of radians()
# for radians
import math
# Printing radians equivalents.
print("180 / pi Degrees is equal to Radians : ", end ="")
print (math.radians(180 / math.pi))
print("180 Degrees is equal to Radians : ", end ="")
print (math.radians(180))
print("1 Degrees is equal to Radians : ", end ="")
print (math.radians(1))
输出:
180/pi Degrees is equal to Radians : 1.0
180 Degrees is equal to Radians : 3.141592653589793
1 Degrees is equal to Radians : 0.017453292519943295
此函数接受“弧度”作为输入并将其转换为等效的度数。
Syntax : degrees(rad)
Parameters :
rad : The radians value that one needs to convert into degrees.
Returns : This function returns the floating point degrees equivalent of argument.
Computational Equivalent : 1 Degrees = pi/180 Radians.
代码#2:展示degrees()
# Python code to demonstrate
# working of degrees()
# for degrees()
import math
# Printing degrees equivalents.
print("pi / 180 Radians is equal to Degrees : ", end ="")
print (math.degrees(math.pi / 180))
print("180 Radians is equal to Degrees : ", end ="")
print (math.degrees(180))
print("1 Radians is equal to Degrees : ", end ="")
print (math.degrees(1))
输出:
pi/180 Radians is equal to Degrees : 1.0
180 Radians is equal to Degrees : 10313.240312354817
1 Radians is equal to Degrees : 57.29577951308232
应用 :
这些函数在与几何相关的数学计算中有许多可能的应用,在天文计算中也有一定的应用。