Answered step by step
Verified Expert Solution
Question
1 Approved Answer
10. Populate a 2-d array of shape (10,15) with Os and 1s chosen randomly. To do this, import the module random first, and use randint(0,1)
10. Populate a 2-d array of shape (10,15) with Os and 1s chosen randomly. To do this, import the module random first, and use randint(0,1) to generate a random bit. Use nditer instead of a loop here. 11. You can reshape arrays using the call np.reshape(a, newshape), where newshape is the tuple corresponding to the new shape desired. Generate an array of 24 increasing numbers starting from o using range(24). Reshape it to get the 3-d matrix a. What happens when the tuple newshape is incompatible with the size of a---je, here a has size 24, but what if newshape is (5,5)? 12. The function np.where(condition, x, y) evaluates the condition. x,y are matrices of the same size. If condition is TRUE in a given position, it outputs the corresponding element of x in that position, else y. Take the matrix from Problem 10 above, and replace every occurence of O with -1 using np.where(condition, x, y) by choosing the arguments wisely. 10. Populate a 2-d array of shape (10,15) with Os and 1s chosen randomly. To do this, import the module random first, and use randint(0,1) to generate a random bit. Use nditer instead of a loop here. 11. You can reshape arrays using the call np.reshape(a, newshape), where newshape is the tuple corresponding to the new shape desired. Generate an array of 24 increasing numbers starting from o using range(24). Reshape it to get the 3-d matrix a. What happens when the tuple newshape is incompatible with the size of a---je, here a has size 24, but what if newshape is (5,5)? 12. The function np.where(condition, x, y) evaluates the condition. x,y are matrices of the same size. If condition is TRUE in a given position, it outputs the corresponding element of x in that position, else y. Take the matrix from Problem 10 above, and replace every occurence of O with -1 using np.where(condition, x, y) by choosing the arguments wisely
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