Question: Write a function to create an n by d np.ndarray of an integer type with numbers from 0 to k (exclusive) filled in. The numbers

Write a function to create an n by d np.ndarray of an integer type with numbers from 0 to k (exclusive) filled in. The numbers should be arranged in order and along the rows. For example, with k=100, n=20 and d=5, your function should return:

array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], ... [90, 91, 92, 93, 94], [95, 96, 97, 98, 99]])

This function should return an integer np.ndarray of shape (n, d).

def create_array(k, n, d): """ This function returns an n by d matrix with numbers from 0 to k (exclusive) filled in. """ assert n * d == k, "Q1: The values of n and d are not compatible with the value of k. " array = None # YOUR CODE HERE # raise NotImplementedError() return array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!