9951 explained code solutions for 126 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

.empty

generate empty Numpy array of the specified shape

10

we're creating empty array of 10 elements

.fill

fill array with specified value

5

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