Python sinh

Python sinh 函数用于计算指定表达式的三角双曲正弦。在本节中,我们将通过一个示例讨论如何在此编程语言中使用 sinh 函数。

sinh 函数的基本语法是:

math.sinh(number);

Number:这是你想要找到双曲正弦值的数字或有效的数值表达式。

  • 如果数字参数是正数或负数,函数将返回正弦值。
  • 如果数字参数不是数字,函数将返回 TypeError。

Python sinh 函数示例

sinh 函数允许你找到数值的三角双曲正弦。在这个例子中,我们将找到不同数据类型的双曲正弦值并显示输出。

提示:请参阅 sin 函数文章以了解正弦函数。

# SINH Function

import math

Tup = (1, 2, 3, -4 , 5)
Lis = [-1, 2, -3.5, -4 , 5]

print('Hyperbolic Sine value of Positive Number = %.2f' %math.sinh(1))
print('Hyperbolic Sine value of Negative Number = %.2f' %math.sinh(-2))

print('Hyperbolic Sine value of Tuple Item = %.2f' %math.sinh(Tup[3]))
print('Hyperbolic Sine value of List Item = %.2f' %math.sinh(Lis[2]))

print('Hyperbolic Sine value of Multiple Numbers = %.2f' %math.sinh(2 + 9 - 7))

print('Hyperbolic Sine value of String Value = ', math.sinh('Hello'))
math sinh Function

首先,我们在正整数和负整数上直接使用了 Python sinh 函数。以下语句计算相应值的双曲正弦。

print('Hyperbolic Sine value of Positive Number = %.2f' %math.sinh(1))
print('Hyperbolic Sine value of Negative Number = %.2f' %math.sinh(-2))

接下来,我们在 元组列表 项上使用了该方法。如果您观察上面的 Python 截图,数学函数在它们上工作得很好。

print('Hyperbolic Sine value of Tuple Item = %.2f' %math.sinh(Tup[3]))
print('Hyperbolic Sine value of List Item = %.2f' %math.sinh(Lis[2]))

接下来,我们直接在多个值上使用了该方法。

print('Hyperbolic Sine value of Multiple Numbers = %.2f' %math.sinh(2 + 9 - 7))

在最后一个语句中,我们尝试对字符串值使用 sinh 函数,它返回了 TypeError 作为输出。

print('Hyperbolic Sine value of String Value = ', math.sinh('Hello'))