Python degrees

The Python degrees math function is used to convert the given angle from Radians to Degrees. In this section, we discuss how to use the degrees function with example.

The syntax of the Python degrees Function is

math.degrees(number);

Number: It can be a number or a valid numerical expression. If the number argument is a positive or negative number, it returns the output. If it is not a number, it returns TypeError.

Python degrees Function Example

This math Function converts the given angle from Radians to Degrees. In this example, we will convert radians of different data types to degrees and prints the output.

  1. Within the first three statements, We used the Zero, Positive integer, and negative integer values as arguments.
  2. Next two statements, We used the Python degrees Function with both the Positive and negative decimal values as arguments.
  3. Next two Python statements, We used this Math function on Tuple and List items. As you see, it is working correctly on them.
  4. Next, We tried directly on multiple values.
  5. Next, we used the Pie values.
  6. In the Last, we used on the String value. As we said before, it returns TypeError as output.
import math

Tup = (1, 2, 8, 4 , 5) # Tuple Declaration
Lis = [8, 3, 9, 5 , 7] # List Declaration

print('Calculating Degree of Zero = %.2f' %math.degrees(0))
print('Calculating Degree of Positive Integer = %.2f' %math.degrees(6))
print('Calculating Degree of Negative Integer = %.2f' %math.degrees(-12))

print('Calculating Degree of Positive Decimal = %.2f' %math.degrees(4.56))
print('Calculating Degree of Negative Decimal = %.2f' %math.degrees(-15.78))

print('Calculating Degree of Tuple Item = %.2f' %math.degrees(Tup[2]))
print('Calculating Degree of List Item = %.2f' %math.degrees(Lis[2]))

print('Calculating Degree of Multiple Numbers = %.2f' %math.degrees(10 + 20 - 25))

print('Calculating Degree of PIE = %.2f' %math.degrees(math.pi))
print('Calculating Degree of PIE/2 = %.2f' %math.degrees(math.pi/2))
print('Calculating Degree of PIE/4 = %.2f' %math.degrees(math.pi/4))
print('Calculating Degree of PIE/6 = %.2f' %math.degrees(math.pi/6))

print('Calculating Degree of String Value = ', math.degrees('3'))
Python DEGREES Function