Python Program – Convert Radians to Degrees

Python Program – Convert Radians to Degrees

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

Degrees = Radians * (180 / π)

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

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

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

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 2.5 Radians to Degrees and print the result to output.

Python Program

import math

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

if __name__ == "__main__":
    # Given Radians
    radians = 2.5

    # Convert Radians to Degrees
    degrees = radiansToDegrees(radians)

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

Output

2.5 radians is equal to 143.2394487827058 degrees

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 Radians to Degrees online by ConvertOnline.org.

Code copied to clipboard successfully 👍