Question: Question 1: Perform the following actions in Python: Use the randn function to create an array with a dimension of 5X5, and use a for
Question 1:
Perform the following actions in Python:
Use the randn function to create an array with a dimension of 5X5, and use a for loop to calculate the sum of all elements in the diagonal of the array.
Choose any three functions to apply to this array.
Question 2:
Use x = np.random.randint(0, 1000, size = (10, 10)) to generate 10x10 array and use a for loop to find out how many even numbers are in it.
Randomly generate a 8x9 array from a normal distribute with mean = 1, sigma = 0.5. Calculate the mean of elements whose indexes have a relation of (i+j)%5 == 0 (i is row index and j is column index).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
