首页 > 编程知识 正文

python爬虫代码示例,好玩的python代码示例

时间:2023-05-04 14:57:58 阅读:258588 作者:1631

np.cosh没有分配

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

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

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

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

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

Syntax of math.cosh() method:

math.cosh()方法的语法:

math.cosh(x)

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

参数: x –是要计算其双曲余弦的数字。

Return value: float – it returns a float value that is the hyperbolic cosine value of the number x.

返回值: float-返回一个浮点值,该值是数字x的双曲余弦值。

Example:

例:

Input: x = 1.5 # function call print(math.cosh(x)) Output: 2.352409615243247 Python代码演示math.cosh()方法的示例 (Python code to demonstrate example of math.cosh() method) # Python code to demonstrate example of # math.cosh() method# importing math moduleimport math # number x = -10print("math.cosh(",x,"): ", math.cosh(x))x = 0print("math.cosh(",x,"): ", math.cosh(x))x = 1.5print("math.cosh(",x,"): ", math.cosh(x))x = 5print("math.cosh(",x,"): ", math.cosh(x))x = 15.45print("math.cosh(",x,"): ", math.cosh(x))

Output

输出量

math.cosh( -10 ): 11013.232920103324math.cosh( 0 ): 1.0math.cosh( 1.5 ): 2.352409615243247math.cosh( 5 ): 74.20994852478785math.cosh( 15.45 ): 2563419.889913628

TypeError example

TypeError示例

# Python code to demonstrate example of # math.cosh() method with exception# importing math moduleimport math # number x = "2.5"print("math.cosh(",x,"): ", math.cosh(x))

Output

输出量

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

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

np.cosh没有分配

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。