3.1.3. Exercises

Tip

Copy this into your Class Notes repo and solve it there. You can find answers here after you try the problems.

import numpy as np

3.1.3.1. Some problems. Put your answers inside the print functions

a = np.arange(4).reshape((2,2))
print("array a:")
print(a)

print("\nMaximum value of a:")
print() # put your answer inside the print

print("\nMinimum value of a:")
print() # put your answer inside the print

print("\nReturn an array of the max in each column of a:")
print()

print("\nReturn an array of the min in each row of a:")
print()

print("\nReturn a, sorted within each row:")
print()

print("\nReturn a, sorted within each column:")
print()
array a:
[[0 1]
 [2 3]]

Maximum value of a:


Minimum value of a:


Return an array of the max in each column of a:


Return an array of the min in each row of a:


Return a, sorted within each row:


Return a, sorted within each column:
b = np.arange(40).reshape((20,2))
print("array b:")
print(b)

print("\nPrint elements of the first column of b above that column's 80th percentile:")
print() 

print("\nCovariance matrix of the columns of b:")
print()
array b:
[[ 0  1]
 [ 2  3]
 [ 4  5]
 [ 6  7]
 [ 8  9]
 [10 11]
 [12 13]
 [14 15]
 [16 17]
 [18 19]
 [20 21]
 [22 23]
 [24 25]
 [26 27]
 [28 29]
 [30 31]
 [32 33]
 [34 35]
 [36 37]
 [38 39]]

Print elements of the first column of b above that column's 80th percentile:


Covariance matrix of the columns of b: