# How to find Cosecant in Python

To calculate the cosecant in Python you can use the **csc()** function of the mpmath module.

from mpmath import csc

csc(x)

The parameter x is the angle measured in radians

The csc () function returns the cosecant of the angle.

**What is the cosecant?** In trigonometry the cosecant is the reciprocal of the sine function. It is equal to infinity if the angle is 0 °, it is one if the angle is 90 ° (sine = 1) or -1 if the angle is 180 °.

**Alternative method**

The cosecant can also be calculated as the reciprocal of the sine.

from math import sin

print(1/sin(x))

**Practical examples**

__Example 1__

To calculate the cosecant of 45 °

>>> from mpmath import csc, radians

>>> x=radians(45)

>>> csc(x)

The radians() function converts the sexagesimal degrees of the angle to radians.

The csc() function calculates the cosecant.

mpf('1.4142135623730951')

The cosecant of 45 ° is approximately 1.41421

__Example 2
__

To calculate the cosecant of 90 °

>>> from math import sin, radians

>>> x=radians(90)

>>> 1/sin(x)

This time the cosecant is calculated as the reciprocal of the function sin (x).

The output result is

mpf('1.0')

The cosecant of an angle of 90 ° is 1.

**Report an error or share a suggestion to enhance this page**