Facebook Page Twitter Page LinkedIn Page
× NumPy Tutorial NumPy Resources


The NumPy real() function is used to return the real part of the complex argument, element-wise. The syntax for using this function is given below:

Syntax

numpy.real(val)

Parameters

val Required. Specify the input array.

Return Value

Returns real component of the complex argument, element-wise.

Example:

The below example shows the usage of real() function.

import numpy as np

Arr = np.array([[1+2j,2+4j],
                [3+6j,4+8j]])

print("Arr is:")
print(Arr)

#real part of Arr
print("\nReal part of Arr is:")
print(np.real(Arr))

The output of the above code will be:

Arr is:
[[1.+2.j 2.+4.j]
 [3.+6.j 4.+8.j]]

Real part of Arr is:
[[1. 2.]
 [3. 4.]]

❮ NumPy - Functions