Python math.radians() function


The math.radians() function in Python is used to convert an angle from degrees to radians. This is useful in various mathematical calculations, especially in trigonometry, where angles are often required in radians.

Syntax

import math result = math.radians(x)
  • x: The angle in degrees that you want to convert to radians.

Return Value

  • Returns the angle in radians as a float.

Examples

  1. Converting degrees to radians:

    import math result = math.radians(180) # Convert 180 degrees to radians print(result) # Output: 3.141592653589793 (which is π)
  2. Converting a smaller angle:

    result = math.radians(45) # Convert 45 degrees to radians print(result) # Output: 0.7853981633974483 (which is π/4)
  3. Converting a negative angle:

    result = math.radians(-90) # Convert -90 degrees to radians print(result) # Output: -1.5707963267948966 (which is -Ď€/2)
  4. Using math.radians() in expressions: You can combine math.radians() with other calculations:

    angle_deg = 30 # 30 degrees result = math.radians(angle_deg) + 1 print(result) # Output: 1.5235987755982988 (approximately)

Summary

  • The math.radians() function converts an angle from degrees to radians.
  • The output is always a float.
  • This function is particularly useful in trigonometric calculations where radians are the standard unit for angles in Python’s math library.