4845 explained code solutions for 96 technologies

python-numpyHow to fill Numpy array with values

import numpy as np

array = np.empty(10)
array.fill(5)ctrl + c
import numpy as np

load Numpy module for Python


generate empty Numpy array of the specified shape


we're creating empty array of 10 elements


fill array with specified value


we're going to fill our array with values of 5