math.degrees() Method in Python:
The math. degrees() method converts a radian angle to a degree angle.
PI (3.14… ) radians are equal to 180 degrees, so 1 radian equals 57.2957795 degrees.
Syntax:
math.degrees(x)
Parameters
x: This is Required. It is a number. A radian value that can be converted into a degree value.
If the parameter is not a number, a TypeError is returned.
Return Value:
Returns a float value indicating the value in degrees.
Examples:
Example1:
Input:
Given Angle = 7.5
Output:
The given angle{ 7.5 } in degrees = 429.7183463481174
Example2:
Input:
Given Angle = 14
Output:
The given angle{ 14 } in degrees = 802.1409131831525
math.degrees() Method with Examples in Python
Method #1: Using Built-in Functions (Static Input)
Approach:
- Import math module using the import keyword.
- Give the number (angle) as static input and store it in a variable.
- Pass the given angle as an argument to the math.degrees() function that converts the given radian angle to a degree angle.
- Store it in another variable.
- Print the given angle in degrees.
- The Exit of the Program.
Below is the implementation:
# Import math module using the import keyword import math # Give the number(angle) as static input and store it in a variable. gvn_angl = 7.5 # Pass the given angle as an argument to the math.degrees() function that # converts the given radian angle to a degree angle. # Store it in another variable. degre_angl = math.degrees(gvn_angl) # Print the given angle in degrees. print("The given angle{", gvn_angl, "} in degrees = ", degre_angl)
Output:
The given angle{ 7.5 } in degrees = 429.7183463481174
Similarly, try for other numbers.
import math gvn_angl = 4 degre_angl = math.degrees(gvn_angl) print("The given angle{", gvn_angl, "} in degrees = ", degre_angl)
Output:
The given angle{ 4 } in degrees = 229.1831180523293
Method #2: Using Built-in Functions (User Input)
Approach:
- Import math module using the import keyword.
- Give the number (angle) as user input using the float(input()) function and store it in a variable.
- Pass the given angle as an argument to the math.degrees() function that converts the given radian angle to a degree angle.
- Store it in another variable.
- Print the given angle in degrees.
- The Exit of the Program.
Below is the implementation:
# Import math module using the import keyword import math # Give the number(angle) as user input using the float(input()) function # and store it in a variable. gvn_angl = float(input("Enter some random number = ")) # Pass the given angle as an argument to the math.degrees() function that # converts the given radian angle to a degree angle. # Store it in another variable. degre_angl = math.degrees(gvn_angl) # Print the given angle in degrees. print("The given angle{", gvn_angl, "} in degrees = ", degre_angl)
Output:
Enter some random number = -10.5 The given angle{ -10.5 } in degrees = -601.6056848873644