Angular Conversion Functions

What You'll Learn: In this tutorial, you'll discover various angular conversion functions available in Python's math module. These functions help you convert angles between degrees and radians.

Angular Conversion Functions

  1. math.degrees(x) - Converts angle x from radians to degrees.
    • Example:

      python
      import math
      radians = math.pi
      degrees = math.degrees(radians)
      print(degrees)  # Output: 180.0
      
  2. math.radians(x) - Converts angle x from degrees to radians.
    • Example:

      python
      import math
      degrees = 180
      radians = math.radians(degrees)
      print(radians)  # Output: 3.141592653589793
      

Try It Yourself: Fun Exercises

  1. Convert Radians to Degrees:
    • Use math.degrees() to convert various angles from radians to degrees, like π/2, π, and 2π.
  2. Convert Degrees to Radians:
    • Use math.radians() to convert various angles from degrees to radians, like 90°, 180°, and 360°.

Summary:

In this Python tutorial, we explored various angular conversion functions available in the math module. These functions help you convert angles between degrees and radians. Keep experimenting and have fun with Python!