The real()
function in NumPy is used to return the real part of the complex argument that is passed to it.
numpy.real(val)
The real()
function takes a single parameter value, val
, which represents an input array that has complex values.
The real()
function returns the real component of the val
parameter value that is passed to it.
import numpy as np# creating an input array of complex valuesx = np.array([1+2j, 2+3j, 1+5j])# implementing the real) functionmyarray = np.real(x)print(x)print(myarray)
numpy
module.x
that has complex values, using the array()
function.real()
function on the input array. We assign the result to a variable called myarray
.x
.myarray
.