Converting Angle from Radians to Degrees

Write a Python program that uses the math module to convert a user input angle from radians to degrees. Return the converted angle.

Example 1:

Input: 1
Output: 57.29577951308232

Example 2:

Input: 3.141592653589793
Output: 180.0

The math module contains a function degrees() that converts an angle from radians to degrees.

import math

# Define the function
def convert_to_degrees(radians):
    return math.degrees(radians)

# Test the function
print(convert_to_degrees(1))  # Output: 57.29577951308232
print(convert_to_degrees(math.pi))  # Output: 180.0

© Let’s Data Science


Unlock AI & Data Science treasures. Log in!