
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Return the Angle of the Complex Argument in Python
To return the angle of the complex argument, use the numpy.angle() method in Python. The method returns the counterclockwise angle from the positive real axis on the complex plane in the range (-pi, pi], with dtype as numpy.float64. The 1st parameter z, A complex number or sequence of complex numbers. The 2nd parameter, deg, return angle in degrees if True, radians if False (default).
Steps
At first, import the required libraries −
import numpy as np
Create an array using the array() method −
arr = np.array([1.0, 1.0j, 1+1j])
Display the array −
print("Array...\n", arr)
Get the type of the array −
print("\nOur Array type...\n", arr.dtype)
Get the dimensions of the Array −
print("\nOur Array Dimension...\n",arr.ndim)
Get the shape of the Array −
print("\nOur Array Shape...\n",arr.shape)
To return the angle of the complex argument, use the numpy.angle() method in Python Numpy. The method returns the counterclockwise angle from the positive real axis on the complex plane in the range (-pi, pi], with dtype as numpy.float64 −
print("\nResult...\n", np.angle(arr))
Example
import numpy as np # Create an array using the array() methodd arr = np.array([1.0, 1.0j, 1+1j]) # Display the array print("Array...\n", arr) # Get the type of the array print("\nOur Array type...\n", arr.dtype) # Get the dimensions of the Array print("\nOur Array Dimension...\n",arr.ndim) # Get the shape of the Array print("\nOur Array Shape...\n",arr.shape) # To return the angle of the complex argument, use the numpy.angle() method in Python Numpy # The method returns the counterclockwise angle from the positive real axis on the complex plane in the range (-pi, pi], with dtype as numpy.float64. print("\nResult...\n", np.angle(arr))
Output
Array... [1.+0.j 0.+1.j 1.+1.j] Our Array type... complex128 Our Array Dimension... 1 Our Array Shape... (3,) Result... [0. 1.57079633 0.78539816]