Python math.atan2()
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 theycoordinate of the point.x: A numeric value representing thexcoordinate 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 mathprint(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:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
- With Certificate
- Beginner Friendly.24 hours