Yes, numpy.ones() function is used to create an array filled with ones. The function takes a tuple as input that specifies the dimensions of the array. You can create a 5x5 matrix of ones and then multiplies it with the row values ranging from 0 to 4 using broadcasting. For example:
The above code uses NumPy’s ones function to create a 5x5 array of ones, and then multiplies each element of the array with the corresponding element of an array generated using NumPy’s arange function. The resulting array is broadcasted to match the shape of the array of ones, stored in a variable and printed to the console using the print function.