math.atan2()

sturrdlefish's avatar
Published Sep 18, 2024
Contribute to Docs

The math.atan2() function in Python takes two numeric values representing a point (x, y) and returns a float that represents the arc tangent of y divided by x. The resulting value is in radians and ranges from to π.

Syntax

math.atan2(y, x)
  • y: A numeric value representing the y coordinate of the point.
  • x: A numeric value representing the x coordinate of the point.

Note: The function takes the y-coordinate (y) as the first parameter and the x-coordinate (x) as the second.

Example

In the example below, the math.atan2() function is used to return the arc tangent of a point (5, 6):

import math
print(math.atan2(6, 5))

The above code gives the following output:

0.8760580505981934

Codebyte Example

The following codebyte example demonstrates how the math.atan2() function works:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy