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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started