Easy Tutorial
❮ Ref Math Pi Python Vscode Setup ❯

Python math.atan2() Method

Python math Module

Python math.atan2(y, x) returns the arctangent of y/x, in radians, where y and x are the coordinates given. The result is between -pi and pi.

Python version: 1.4

Syntax

The syntax for the math.atan2() method is as follows:

math.atan2(y, x)

Parameter Description:

Return Value

Returns a floating-point number representing the arctangent of y/x, with the result between -pi and pi.

Example

The following example returns the arctangent of y/x:

Example

# Import math package
import math

# Print the arctangent of y/x
print(math.atan2(8, 5))
print(math.atan2(20, 10))
print(math.atan2(34, -7))

Output result:

1.0121970114513341
1.1071487177940904
1.7738415440483617

Python math Module

❮ Ref Math Pi Python Vscode Setup ❯