np.empty() do in NumPy?np.empty() creates a new array of a given shape and type, but does not initialize the entries. The values in the array are random and depend on the memory state.
np.empty()?Because the array is uninitialized, it contains whatever data was already in memory. This means the values are unpredictable and should not be used before setting them explicitly.
np.empty() different from np.zeros()?np.zeros() creates an array filled with zeros, initializing all values. np.empty() creates an array without initializing values, so it is faster but contains garbage data.
np.empty().<pre>import numpy as np
arr = np.empty((2, 3))
print(arr)</pre><p>This prints a 2 by 3 array with random values from memory.</p>np.empty()?It is useful when you want to create an array quickly and will fill all values later, so you don't waste time initializing with zeros or other values.
np.empty((3,3)) return?np.empty() creates an array without initializing values, so it contains random data from memory.
np.empty() be faster than np.zeros()?np.empty() skips initializing values, so it runs faster than np.zeros() which sets all values to zero.
np.empty()?Since np.empty() arrays have random data, you must assign values before using them.
All these forms correctly specify the shape for np.empty() to create a 1D array of length 4.
np.empty()?np.zeros() creates an array filled with zeros, unlike np.empty() which is uninitialized.
np.empty() does and why its output values are unpredictable.np.empty() is better than np.zeros().