Friday, October 10, 2025
HomeLanguagesPython | Numpy ndarray.real()

Python | Numpy ndarray.real()

With the help of Numpy ndarray.real() method, we can find the real values in an imaginary expressions by just using ndarray.real() method. Remember resulting data type for the real value is ‘float64’.

Syntax : ndarray.real()

Return : Array of Real values having dtype ‘float64’

Example #1 :
In this example we can see that we get the array of real values using ndarray.real() method and we are also trying to print the dtype of those real values.




# import the important module in python
import numpy as np
          
# make an array with numpy
gfg = np.array([1 + 2j, 2 + 3j])
          
# applying ndarray.real() method
neveropen = np.real(gfg)
    
print(neveropen, end ='\n\n')
print(np.real(neveropen).dtype)


Output:

[ 1.  2.]

'float64'

Example #2 :




# import the important module in python
import numpy as np
          
# make an array with numpy
gfg = np.array([1 + 2j, 2 + 3j])
gfg = np.sqrt(gfg)
          
# applying ndarray.real() method
neveropen = np.real(gfg)
    
print(neveropen, end ='\n\n')
print(np.real(neveropen).dtype)


Output:

[ 1.27201965  1.67414923]

float64
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32349 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7097 POSTS0 COMMENTS
Thapelo Manthata
6792 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS