Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Python cosh

by suresh

The Python cosh function calculates the Trigonometric Hyperbolic Cosine for the specified expression. In this section, we discuss how to use cosh function in Python Programming language with example.

The syntax of the cosh Function in Python Programming Language is

math.cosh(number);

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

  • If the number argument is a positive or negative number, the cosh function returns the Hyperbolic Cosine value.
  • If the number argument is not a number, the cosh function returns TypeError.

Python cosh Function Example

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

TIP: Please refer to the Python cos Function article to understand the Cosine Function.

# Python COSH Function

import math

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

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

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

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

print('Hyperbolic Cosine value of String Value = ', math.cosh('Hello'))
Python COSH Function

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

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

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

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

Next, we used the cosh Math function directly on multiple values.

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

Within the last statement, we tried cosh Function on the string value, and it returns TypeError.

print('Hyperbolic Cosine value of String Value = ', math.cosh('Hello'))

Placed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda Function
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File Handling
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python numpy concatenate
  • Python numpy Array shape
  • Python pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python substring
  • Python Programming Examples

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy