带有Python示例的math.degrees()方法
Pythonmath.degrees()方法
math.degrees()方法是数学模块的一种库方法,用于将角度值从弧度转换为度,它接受一个数字并返回以度为单位的角度值。
注意:math.degrees()方法仅接受数字,如果我们提供除数字以外的其他任何内容,它将返回错误TypeError–“TypeError:需要浮点数”。
它的语法math.degrees()方法:
math.degrees(x)
Parameter(s):x–是要转换为度的弧度数。
返回值:float-它返回一个浮点值,即以度为单位的角度值。
示例
Input:
x = 10.25
#函数调用
print(math.degrees(x))
Output:
587.2817400090938Python代码演示示例math.degrees()方法
#Python代码演示示例
# math.degrees() method
#导入数学模块
import math
#弧度数
x = 0
print("math.degrees(",x,"): ", math.degrees(x))
x = 0.25
print("math.degrees(",x,"): ", math.degrees(x))
x = 10.25
print("math.degrees(",x,"): ", math.degrees(x))
x = -0.25
print("math.degrees(",x,"): ", math.degrees(x))输出结果
math.degrees( 0 ): 0.0 math.degrees( 0.25 ): 14.32394487827058 math.degrees( 10.25 ): 587.2817400090938 math.degrees( -0.25 ): -14.32394487827058
TypeError示例
#Python代码演示示例
# math.degrees() method with exception
#导入数学模块
import math
#弧度数
x = "10"
print("math.degrees(",x,"): ", math.degrees(x))输出结果
Traceback (most recent call last):
File "/home/main.py", line 9, in <module>
print("math.degrees(",x,"): ", math.degrees(x))
TypeError: a float is required热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短