Mar-14-2019, 12:11 PM
Your code should be something like this:
import numpy as np def is_symmetric(A): """Returns True if input matrix is symmetric, False - otherwise. Parameters ========== :param A: a matrix (2D array, Numpy array or list of lists) to be tested; :rtype: bool; :returns: True if A == A.T, otherwise - False. """ return np.array(A) == np.array(A).T def is_skew(A): """Returns True if input matrix is skew, False - otherwise. # TODO: Docs needed (You need to accomplish docstring here!) """ return np.array(A) == -np.array(A).T def test_matrix(A): """Test matrix for special form Returns 1 if input matrix is symmetric, -1 if input matrix is skew, 0 - otherwise. Parameters ========== :param A: # TODO: Docs needed """ if is_symmetric(A): return 1 # TODO: Additional conditions should be added if __name__ == '__main__': a, b, c, d, e, f, g, h, i = 1, 2, 3, 4, 5, 6, 7, 8, 9 A = [[a, b, c], [d, e, f], [g, h, i]] print("Testing matrix A: ", test_matrix(A))You need to complete the code snippet I wrote...