# Python tanh

Python tanh math function calculates trigonometric hyperbolic tangent of a given expression. The syntax of the Python tanh Function is

`math.tanh(number);`

Number: It can be a number or a valid numerical expression for which you want to find hyperbolic Tangent value.

• If the number argument is a positive or Negative number, the tanh function returns the hyperbolic Tangent value.
• If it is not a number, the tanh function returns TypeError.

## Python TANH Function Example

The Python tanh Function allows you to find the trigonometric Hyperbolic tangent for numeric values. In this tanh example, we are going to find the hyperbolic tangent values for different data types and display the output

TIP: Please refer to the Python tan Function article to understand the Tangent Function.

```# Python TANH Function

import math

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

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

print('Hyperbolic Tangent value of Tuple Item = %.2f' %math.tanh(Tup))
print('Hyperbolic Tangent value of List Item = %.2f' %math.tanh(Lis))

print('Hyperbolic Tangent of Multiple Numbers = %.2f' %math.tanh(2 + 9 - 7))

print('Hyperbolic Tangent value of String Value = ', math.tanh('Hello'))```

First, we used the tanh Function directly on both the Positive integer and negative integer. The following statements find the hyperbolic Tangent of the corresponding values.

```print('Hyperbolic Tangent value of Positive Number = %.2f' %math.tanh(1))
print('Hyperbolic Tangent value of Negative Number = %.2f' %math.tanh(-2))```

Next, We used the tanh Function on Python Tuple and List items. If you observe the above screenshot, the Math function is working perfectly on them.

```print('Hyperbolic Tangent value of Tuple Item = %.2f' %math.tanh(Tup))
print('Hyperbolic Tangent value of List Item = %.2f' %math.tanh(Lis))```

Next, We used the tanh Function directly on multiple values.

`print('Hyperbolic Tangent of Multiple Numbers = %.2f' %math.tanh(2 + 9 - 7))`

Within the last statement, we tried the tanh Function on the String value, and it returns TypeError

`print('Hyperbolic Tangent value of String Value = ', math.tanh('Hello'))`