Thursday, January 22, 2026
HomeLanguagesnumpy.result_type() function – Python

numpy.result_type() function – Python

numpy.result_type() function returns the type that results from applying the NumPy type promotion rules to the arguments.

NumPy type promotion by example :
Suppose calculating 3*arr, where arr is an array of 32-bit floats, intuitively should result in a 32-bit float output. If the 3 is a 32-bit integer, the NumPy rules indicate it can’t convert losslessly into a 32-bit float, so a 64-bit float should be the result type.

Syntax : numpy.result_type(arrays_and_dtypes)

Parameters :
arrays_and_dtypes : [list of arrays and dtypes] The operands of some operation whose result type is needed.
Return : [dtype] Return the result type.

Code #1 :




# Python program explaining
# numpy.result_type() function
          
# importing numpy as geek 
import numpy as geek 
      
gfg = geek.result_type('f4', 'i8')
    
print (gfg)


Output :

float64

 
Code #2 :




# Python program explaining
# numpy.result_type() function
          
# importing numpy as geek 
import numpy as geek 
      
gfg = geek.result_type(3, geek.arange(7, dtype = 'i1'))
    
print (gfg)


Output :

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

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS