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 degrees function in Python with example.

The syntax of the degrees Function in Python Programming Language 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, the degrees function returns the output. If it is not a number, the degrees function returns TypeError.

Python degrees Function Example

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

# Python DEGREES Function

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
  1. Within the first three statements, We used the degrees Function with 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 Python Math function on Python Tuple and Python List items. As you see, the degrees function is working correctly on them.
  4. Next, We tried degrees Function directly on multiple values.
  5. Next, we used the degrees Function on Pie values.
  6. In the Last, we used the degrees Function on the String value. As we said before, it returns TypeError as output.