# Return the angle of the complex argument in degrees in Python

PythonNumpyServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

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, deg = True))

## Example

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, deg = True))

## 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. 90. 45.]