';
To return the real part of the complex argument, use the numpy.real() method in Python. Themethod returns the real component of the complex argument. If val is real, the type of val is used forthe output. If val has complex elements, the returned type is float. The 1st parameter, val is theinput array
Steps
At first, import the required libraries −
import numpy as np
Create an array using the array() method −
arr = np.array([56.+0.j , 27.+0.j , 68.+0.j , 23.+0.j])
Display the array −
print("Our Array...\n",arr)
Check the Dimensions −
print("\nDimensions of our Array...\n",arr.ndim)
Get the Datatype −
print("\nDatatype of our Array object...\n",arr.dtype)
Get the Shape −
print("\nShape of our Array...\n",arr.shape)
To return the real part of the complex argument, use the numpy.real() method in Python. Themethod returns the real component of the complex argument. If val is real, the type of val is used forthe output. If val has complex elements, the returned type is float. The 1st parameter, val is theinput array −
print("\nResult (Real part)...\n",np.real(arr))
Example
import numpy as np# Create an array using the array() methodarr = np.array([56.+0.j , 27.+0.j , 68.+0.j , 23.+0.j])# Display the arrayprint("Our Array...\n",arr)# Check the Dimensionsprint("\nDimensions of our Array...\n",arr.ndim)# Get the Datatypeprint("\nDatatype of our Array object...\n",arr.dtype)# Get the Shapeprint("\nShape of our Array...\n",arr.shape)# To return the real part of the complex argument, use the numpy.real() method in Pythonprint("\nResult (Real part)...\n",np.real(arr))
Output
Our Array...[56.+0.j 27.+0.j 68.+0.j 23.+0.j]Dimensions of our Array...1Datatype of our Array object...complex128Shape of our Array...(4,)Result (Real part)...[56. 27. 68. 23.]
Updated on: 01-Mar-2022
206 Views
- Related Articles
- Change the real part of the complex argument in Python
- Return the imaginary part of the complex argument in Python
- Change the imaginary part of the complex argument in Python
- Return the angle of the complex argument in Python
- Return the angle of the complex argument in degrees in Python
- Return the angle of the complex argument in radians in Python
- Golang Program to get the real part from a Complex number
- Swift Program to get the real part from a Complex number
- Haskell Program to get the real part from a Complex number
- Argument of Complex Numbers
- Return the square of the complex-value input in Python
- Compute the eigenvalues of a complex Hermitian or real symmetric matrix in Python
- Return real parts if input is complex with all imaginary parts close to zero in Python
- Return the base 2 logarithm for complex value input in Python
- Fourier Transform of Complex and Real Functions
Advertisem*nts
';