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

math.sin() method is a library method of math module, it is used to get the sine of the number in radians, it accepts a number returns the cosine of the given number in radians.

math.sin()方法数学模块的库方法,用于获取以弧度为单位的数字的正弦值,它接受一个以弧度为单位返回给定数字的余弦值的数字。

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

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

Syntax of math.sin() method:

math.sin()方法的语法:

    math.sin(x)

Parameter(s): x – is the number whose sine to be calculated.

参数: x –是要计算其正弦的数字。

Return value: float – it returns a float value that is the sine value of the number x radians.

返回值: float-它返回一个浮点值,该值是数字x弧度的正弦值。

Example:

例:

    Input:
a = 0.278
# function call
print(math.sin(a))
Output:
0.27443298625778634

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

# python code to demonstrate example of
# math.sin() method
# importing math module
import math
# number
a = -1
print("sin(",a,") is = ", math.sin(a))
a = 0
print("sin(",a,") is = ", math.sin(a))
a = 0.278
print("sin(",a,") is = ", math.sin(a))
a = 1
print("sin(",a,") is = ", math.sin(a))

Output

输出量

sin( -1 ) is =  -0.8414709848078965
sin( 0 ) is =  0.0
sin( 0.278 ) is =  0.27443298625778634
sin( 1 ) is =  0.8414709848078965

TypeError example

TypeError示例

# python code to demonstrate example of
# math.sin() method with an exception
# importing math module
import math
# number
a = "2"
print("sin(",a,") is = ", math.sin(a))

Output

输出量

Traceback (most recent call last):
File "/home/main.py", line 9, in <module>
print("sin(",a,") is = ", math.sin(a))
TypeError: a float is required

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

带有Python示例的math.sin()方法相关推荐

  1. python中 math.isfinite返回值为false_带有Python示例的math.isfinite()方法

    Python math.isfinite() 方法 math.isfinite()方法是数学模块的一种库方法,用于检查给定数字是否为非有限数,它接受数字(整数/浮点数,有限,无限或NaN),如果数字既 ...

  2. python中math.ceil是什么意思_带有Python示例的math.ceil()方法

    Python math.ceil() 方法 math.ceil()方法是数学模块的库方法,用于获取给定数字的ceil值,它接受数字/数字表达式并返回大于该数字的最小整数值. 注意:如果数字是整数值,则 ...

  3. math求旋转角度 python_带有Python示例的math.degrees()方法

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

  4. python教程cos_带有Python示例的math.cos()方法

    Python math.cos() 方法 math.cos()方法是数学模块的库方法,用于获取弧度数的余弦值,它接受一个数字,返回给定弧度的余弦值. 注意: math.cos()方法接受的唯一的号码, ...

  5. python math.sinh_带有Python示例的math.sinh()方法

    Python math.sinh() 方法 math.sinh()方法是数学模块的一种库方法,用于获取以弧度为单位的给定数字的双曲正弦值,它接受一个数字并返回双曲正弦值. 注意: math.sinh( ...

  6. math.trunc_带有Python示例的math.trunc()方法

    math.trunc Python math.trunc()方法 (Python math.trunc() method) math.trunc() method is a library metho ...

  7. np.isfinite_带有Python示例的math.isfinite()方法

    np.isfinite Python math.isfinite()方法 (Python math.isfinite() method) math.isfinite() method is a lib ...

  8. factorial函数_带有Python示例的math.factorial()方法

    factorial函数 Python math.factorial()方法 (Python math.factorial() method) math.factorial() method is a ...

  9. np.copysign_带有Python示例的math.copysign()方法

    np.copysign Python math.copysign()方法 (Python math.copysign() method) math.copysign() method is a lib ...

最新文章

  1. 记一次shell脚本推后台stopped的问题
  2. 高并发服务优化篇:从RPC预热转发看服务端性能调优
  3. 在ubuntu下安装free pascal
  4. 自然数幂和取模问题进一步探究
  5. 一步步编写操作系统 45 用c语言编写内核2
  6. gps卫星位置计算程序matlab_科研项目 | BD/ GPS卫星导航仿真测试系统研究
  7. 计算机安全防范系统维护,安防系统维护与设备维修(全彩)
  8. 数据挖掘:模型选择——树模型
  9. 最长公共子序列php,动态规划(最长公共子序列LCS)
  10. OpenStack峰会喊你回家吃饭
  11. SiamFC复现结果
  12. 在html中生成动态表格数据,JavaScript实现网页动态生成表格
  13. 74LS 系列与 74HC,74HCT,CD系列的区别
  14. 淘宝月度活跃用户近7亿 超70%新增消费者来自下沉市场
  15. 打印机驱动无法安装到计算机是,电脑打印机无法安装驱动的解决方法
  16. Python实战回归模型-消费者人群画像-信用智能评分(基于中国移动用户数据)
  17. 学习Python一定要吃透这68个内置函数,强烈建议收藏(文末附本周送书和抽奖)...
  18. 2008-09赛季NBA直播表(cctv5 广东体育)
  19. zabbix服务端搭建
  20. 托福100分什么水平

热门文章

  1. java怎么生成字母_java自动生成字母
  2. 小学阅读方法六种_小学生掌握了这些语文答题方法,轻松应对阅读理解,不再是难事...
  3. js中var、let、const区别
  4. CSS 属性 - 伪类和伪元素的区别
  5. css渲染(二) 文本
  6. intellij idea中解决java.lang.VerifyError: Expecting a stackmap frame at branch target的方法
  7. BZOJ - 4520 K远点对
  8. 软件测试白皮书-等价类
  9. 3. 跟踪标记 (Trace Flag) 1204, 1222 抓取死锁信息
  10. 外中断02 - 零基础入门学习汇编语言70