Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.atan2() Method

Python math.atan2() Method

Python math Module Python math Module

Python math.atan2(y,x) Returns the arctangent of the given y and x coordinate values, atan(y / x), in radians, with the result between -pi and pi.

Python version: 1.4

Syntax

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

math.atan2(y, x)

Parameter Description:

Return Value

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

Example

The following example returns the arctangent of y/x:

Example

Import the math package

import

math

Output the y/x arctangent values

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 Python math Module