np Built-in Functions for Array Templates

Name some built-in NumPy functions that create specific types of arrays.

Answer
  • np.ones(shape): creates an ndarray filled with ones.

  • np.zeros(shape): creates an ndarray filled with zeros.

  • np.full(shape, fill_value): creates an ndarray filled with a specific value.

  • np.arange(start, stop, step): creates a range-based ndarray.

  • np.linspace(start, stop, num): creates an ndarray of evenly spaced values.

Back to collection