Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

Python atan2

by suresh

The Python atan2 function is one of the Python Math function that returns the angle (in radius) from the X-Axis to the specified point (y, x). In this section, we discuss how to use atan2 function in Python Programming language with example.

The syntax of the atan2 Function in Python Programming Language is

math.atan2(y, x);
  • X: It can be a number or a valid numerical expression which represent Cartesian X – Coordinate.
  • Y: It can be a number or a valid numerical expression which represent Cartesian Y – Coordinate.

HINT: If we pass any non-numeric values to the atan2 Function, then atan2 function return TypeError as output

Python atan2 Function Example

The atan2 Function in Python Language returns the angle (in radius) from the X -Axis to the specified point (y, x). In this atan2 example, We are going to find the same with different data types and display the output

TIP: Please refer to the Python tan Function article to understand the Python Tangent Function.

# Python ATAN2 Function

import math

Tup = (1, 2, 3, -4 , 5)
Lis = [-1, 2, -3.5, -4 , 5]

print('Tangent value of Positive Number = %.2f' %math.atan2(2, 4))
print('Tangent value of Negative Number = %.2f' %math.atan2(-1, 6))

print('Tangent value of Tuple Item = %.2f' %math.atan2(Tup[3], Tup[2]))
print('Tangent value of List Item = %.2f' %math.atan2(Lis[2], Lis[4]))

print('Tangent value of Multiple Number = %.2f' %math.atan2(2 + 7 - 4, 9-5))

print('Tangent value of String Number = %.2f', math.atan2('Hello', 'Python'))

OUTPUT

Python ATAN2 Function

ANALYSIS

First, we used the atan2 Function directly on both the Positive integer and negative integer. The following statements find the angle (in radius) for the corresponding values.

print('Tangent value of Positive Number = %.2f' %math.atan2(2, 4))
print('Tangent value of Negative Number = %.2f' %math.atan2(-1, 6))

Next, we used the atan2 Function on Python Tuple and Python List items. If you see the above screenshot, the atan2 function is working perfectly on them.

print('Tangent value of Tuple Item = %.2f' %math.atan2(Tup[3], Tup[2]))
print('Tangent value of List Item = %.2f' %math.atan2(Lis[2], Lis[4]))

Next, we used the atan2 Math function on multiple values.

print('Tangent value of Multiple Number = %.2f' %math.atan2(2 + 7 - 4, 9-5))

Within the last statement, we tried atan2 Function on the string value, and it returns TypeError as output

print('Tangent value of String Number = %.2f', math.atan2('Hello', 'Python'))

Placed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python Numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python Numpy concatenate
  • Python Numpy Array shape
  • Python Pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python Substring
  • Python Programming Examples
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy