css degrees_带有Python示例的math.degrees()方法

css degrees

Python math.degrees()方法 (Python math.degrees() method)

math.degrees() method is a library method of math module, it is used to convert angle value from radians to degree, it accepts a number and returns the angle value in degree.

math.degrees()方法数学模块的库方法,用于将角度值从弧度转换为度,它接受一个数字并返回以度为单位的角度值。

Note: math.degrees() method accepts only numbers, if we provide anything else except the number, it returns error TypeError"TypeError: a float is required".

注意: math.degrees()方法仅接受数字,如果我们提供除数字以外的任何其他内容,它将返回错误TypeError“ TypeError:需要浮点数”

Syntax of math.degrees() method:

math.degrees()方法的语法:

    math.degrees(x)

Parameter(s): x – is the number in radians to be converted into degree.

参数: x –是要转换为度的弧度数。

Return value: float – it returns a float value that is the angle value in degree.

返回值: float-它返回一个浮点值,即以度为单位的角度值。

Example:

例:

    Input:
    x = 10.25

    # function call
    print(math.degrees(x))

    Output:
    587.2817400090938

Python代码演示math.degrees()方法的示例 (Python code to demonstrate example of math.degrees() method)

# Python code to demonstrate example of 
# math.degrees() method

# importing math module
import math 

# number in radians
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))

Output

输出量

math.degrees( 0 ):  0.0
math.degrees( 0.25 ):  14.32394487827058
math.degrees( 10.25 ):  587.2817400090938
math.degrees( -0.25 ):  -14.32394487827058

TypeError example

TypeError示例

# Python code to demonstrate example of 
# math.degrees() method with exception

# importing math module
import math 

# number in radians
x = "10"
print("math.degrees(",x,"): ", math.degrees(x))

Output

输出量

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 


翻译自: https://www.includehelp.com/python/math-degrees-method-with-example.aspx

css degrees

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值