To convert degrees to radians for use in trigonometric functions in Python, the easiest way is with the **math.radians()** function from the Python math module.

```
import math
radians = math.radians(60)
```

The Python math module has many powerful functions which make performing certain calculations in Python very easy.

One such calculation which is very easy to perform in Python is converting degrees to radians.

We can convert degrees to radians easily with the Python math module **radians()** function.

To do so, we need to pass any number to the Python math **radians()** function.

Below are a few examples of how to use the **radians()** function to convert different angles, in degrees, to radians with in Python.

```
import math
print(math.radians(0))
print(math.radians(30))
print(math.radians(60))
print(math.radians(90))
#Output:
0.0
0.5235987755982988
1.0471975511965976
1.5707963267948966
```

If you’d like to go the other way, converting radians to degrees, you can use the math.degrees() Python function.

## Converting Degrees to Radians Without the math Module in Python

Converting degrees to radians is a very easy formula. To convert degrees to radians, all we need to do is multiply the degrees by pi divided by 180.

We can convert degrees to radians without the help of the math module easily in Python.

Below is a user-defined function which will convert degrees to radians for us in our Python code.

```
def degrees_to_radians(degrees):
return degrees * (math.pi/180)
```

Let’s test the function to verify that we get the same results as the **math.radians()** Python function.

```
def degrees_to_radians(degrees):
return degrees * (math.pi/180)
print(degrees_to_radians(0))
print(degrees_to_radians(30))
print(degrees_to_radians(60))
print(degrees_to_radians(90))
#Output:
0.0
0.5235987755982988
1.0471975511965976
1.5707963267948966
```

As you can compare for yourself to the example above, we get the same results as using **math.radians()**

Hopefully this post was helpful for you to learn how to convert degrees to radians in Python with and without the **math.radians()** Python function.

## Leave a Reply