Solution Exercise 8: Duplicating a numpy matrix
Exercise 8 Generate a numpy matrix by repeating a smaller 2-dimensional, 5 times. Solution import numpy as npA = np.array([[5 , 7], [3 , 9]])C = np.tile(A , 5)print(C)"""attach:[[5 7…
Python Courses & Exercises with solutions !
Exercise 8 Generate a numpy matrix by repeating a smaller 2-dimensional, 5 times. Solution import numpy as npA = np.array([[5 , 7], [3 , 9]])C = np.tile(A , 5)print(C)"""attach:[[5 7…
Exercise 7 Stack 2 numpy arrays vertically, i.e. 2 arrays with the same last dimension (same number of columns). Solution import numpy as npA = np.array([[1 , 2], [3 ,…
Exercise 6 Stack 2 numpy marices horizontally, i.e. 2 arrays having the same 1st dimension (same number of rows). Solution import numpy as npA = np.array([[1 , 2], [6 ,…
Exercise 5 Convert a numpy binary matrix (containing only '0' and '1') to a numpy boolean matrix (i.e. '1' will be replaced by 'True' and '0' by 'False') Solution import…
Exercise 4 Resume the previous exercise (Exercise3) without using the trace() method. Solution import numpy as npdef matrix_trace(A): n = len(A) # initialization of trace of A trace = 0…
Exercise 3 Write a python function that takes a numpy matrix as a parameter and returns its trace. We recall that the trace of a square matrix A = (ai…
Contenu du cours About hyperlinks Link to a URL address Link to a file Link to E-mail box Link in the same page 1. About hyperlinks In order to…