numpy.empty () in Python

NumPy | Python Methods and Functions

numpy.empty (shape, dtype = float, order = & # 39; C & # 39;): return a new array of the given shape and type with random values. 
Parameters :

 - & gt;  shape:  Number of rows - & gt;  order:  C_contiguous or F_contiguous - & gt;  dtype:  [optional, float (by Default)] Data type of returned array. 

# Python Programming Illustrative
# numpy.empty method

 

import numpy as geek

 

b = geek.empty ( 2 , dtype = int )

print ( " Matrix b: " , b)

 

a = geek.empty ([ 2 , 2 ], dtype = int )

print ( "Matrix a:" , a)

 

c = geek.empty ([ 3 , 3 ])

print ( "Matrix c:" , c)

Output:

 Matrix b: [0 1079574528] Matrix a: [[0 0] [ 0 0]] Matrix a: [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]] 

Note: empty , unlike zeros, not a mustache Sets the array values ​​to zero, and therefore may be slightly faster. 
Also, these codes will not work on an online ID. Please run them on your systems to see how they work





Get Solution for free from DataCamp guru