# How to Convert Degrees to Radians in Python?

In this Python tutorial, I will explain to you, how to convert degrees to radians in Python.

• Degrees: A full circle is divided into 360 equal parts, each part is known as a degree.
• Radians: In radians, a full circle is equal to 2π, where π (pi) is approximately equal to 3.14159265358979323846.

The relationship between degrees and radians is given by the formula:

``radians = degrees * (π / 180)``

Python has a built-in module that can be used for the mathematical task on numbers. The math module contains functions for calculating the various trigonometric ratios for a given angle.

The math module presents two angles conversion function which is degrees() and radians(). The math module has a set of methods.

In Python, math.radians() method is used to convert a degree value to radians. So, we will first import math module.

Example:

``````import math

Once you execute the code, “math.radians(120)”, will print like 2.0943951023931953.

You can refer to the below screenshot:

This is how to convert degrees to radians in Python.

## Convert Degrees to Radians in Python

Here is a different way to convert degrees to radians in Python.

• The first step is to import the necessary libraries. Python’s `math` library contains a constant for `π` (pi) which we will be using.
``import math``
• Next, let’s create a function that takes an angle in degrees as an argument and returns its equivalent in radians.
``````def degrees_to_radians(degrees):
return degrees * (math.pi / 180)``````
• In a practical program, you might want to allow the user to input the angle in degrees. You can do this using the input() function.
``````degrees = float(input("Enter angle in degrees: "))
• Python’s math library also includes a built-in function to convert degrees to radians, which is math.radians(). This can be used as an alternative to the function we created earlier.
``````radians = math.radians(degrees)

Below is the complete code:

``````import math

return degrees * (math.pi / 180)

# Using custom function
degrees = float(input("Enter angle in degrees: "))

# Using built-in function

You can check out the output like below:

## Convert degrees to radians using NumPy in Python

Let’s see how to convert degrees to radians using NumPy in Python.

To convert degrees to radians in Python, we have to import numpy package first. It has an inbuilt function name deg2rad() which can directly convert degrees to radians.

Example:

``````import numpy as np