日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

tanh python_带有Python示例的math.tanh()方法

發(fā)布時間:2025/3/11 python 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tanh python_带有Python示例的math.tanh()方法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

tanh python

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

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

math.tanh()方法是數(shù)學(xué)模塊的庫方法,用于獲取以弧度為單位的給定數(shù)字的雙曲正切值,它接受一個數(shù)字并返回雙曲正切值。

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

注意: math.tanh()方法僅接受數(shù)字,如果我們提供除數(shù)字以外的任何其他內(nèi)容,它將返回錯誤TypeError – “ TypeError:需要浮點(diǎn)數(shù)” 。

Syntax of math.tanh() method:

math.tanh()方法的語法:

math.tanh(x)

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

參數(shù): x –是要計(jì)算其雙曲正切值的數(shù)字。

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

返回值: float-返回一個浮點(diǎn)值,該值是數(shù)字x的雙曲正切值。

Example:

例:

Input:x = 1.5# function callprint(math.tanh(x))Output:0.9051482536448664

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

# Python code to demonstrate example of # math.tanh() method# importing math module import math # number x = -10 print("math.tanh(",x,"): ", math.tanh(x))x = 0 print("math.tanh(",x,"): ", math.tanh(x))x = 1.5 print("math.tanh(",x,"): ", math.tanh(x))x = 5 print("math.tanh(",x,"): ", math.tanh(x))x = 15.45 print("math.tanh(",x,"): ", math.tanh(x))

Output

輸出量

math.tanh( -10 ): -0.9999999958776927 math.tanh( 0 ): 0.0 math.tanh( 1.5 ): 0.9051482536448664 math.tanh( 5 ): 0.9999092042625951 math.tanh( 15.45 ): 0.999999999999924

TypeError example

TypeError示例

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

Output

輸出量

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

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

tanh python

總結(jié)

以上是生活随笔為你收集整理的tanh python_带有Python示例的math.tanh()方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。