Python Math – Convert degrees to radians

In this post we will be creating a Python script that will convert a given number of degrees to radians. The script will take a number via input and covert it to radians before printing to output. To achieve this we will be using the math module, which provides access to the mathematical functions defined by the C standard.

See the snippet of Python code below which uses the ‘radians()’ function, the function will convert the given number of degrees to radians and then return this to output.

import math

while True:
    Number=int(input("Please Enter degrees: "))

An example of the code being run can be seen below.

Please Enter degrees: 90
1.5707963267948966 radians
Please Enter degrees: 180
3.141592653589793 radians
Please Enter degrees: 360
6.283185307179586 radians

Take a look at some of our other content around the Python programming language by clicking here.

Leave a Reply