Python Program – Convert Degrees to Radians

Python Program – Convert Degrees to Radians

To convert an angle from Degrees to Radians in Python, you can use the following formula in the program.

Radians = Degrees * (π / 180)

Let us write a function, that takes the Degrees value as argument, computes the Radians using the above formula, and returns the result.

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

You may use this function, in your program, to convert Degrees to Radians.

Since we have used math.pi in the program, please remember to import math module in the import section.

The following is an example program, where we shall use the above conversion function, and convert 100 Degrees to Radians and print the result to output.

Python Program

import math

# Function that converts Degrees to Radians
def degreesToRadians(degrees):
    return degrees * (math.pi / 180)

if __name__ == "__main__":
    # Given Degrees
    degrees = 100

    # Convert Degrees to Radians
    radians = degreesToRadians(degrees)

    print(f"{degrees} degrees is equal to {radians} radians")

Output

100 degrees is equal to 1.7453292519943295 radians

To implement the formula, we used Python Multiplication, and Python Division, from Arithmetic Operators.

To verify your output, you can use this online tool: Convert Degrees to Radians online by ConvertOnline.org.

Code copied to clipboard successfully 👍