• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / math.radians() python – How to Convert Degrees to Radians in Python

math.radians() python – How to Convert Degrees to Radians in Python

February 4, 2022 Leave a Comment

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.

Other Articles You'll Also Like:

  • 1.  Pascal’s Triangle in Python
  • 2.  How to Add Two Numbers in Python
  • 3.  pandas percentile – Calculate Percentiles of Series or Columns in DataFrame
  • 4.  Get pandas Column Names as List in Python
  • 5.  Create Symbolic Link with Python os.symlink() Function
  • 6.  PROC REG Equivalent in Python
  • 7.  Difference Between read(), readline() and readlines() in Python
  • 8.  pandas product – Get Product of Series or DataFrame Columns
  • 9.  Using Python to Count Even Numbers in List
  • 10.  How to Add Commas to Numbers in Python

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy