A matrix is symmetric if every element of the matrix at row i and column j is
Question:
A matrix is symmetric if every element of the matrix at row i and column j is equal to theelement at row j and column i. A matrix can only be symmetric if it is a square matrix(that is, the matrix has the same number of rows as columns). Your task is to construct a Python function called symmetric which expects one argument: a two-dimensional table representing a square matrix. Your function should return True if the matrix is symmetric and False otherwise. You may assume that the table passed as the argument will have the same number of rows as columns and that it will contain only numbers. Here are some examples of how your function should behave:
>>> m1 = [[5, 4, 3], [4, 0, 7], [3, 7, -1]]
>>> m2 = [[5, 4, 3], [4, 0, 6], [3, 7, -1]]
>>> m3 = [[0, 0], [0, 0]]
>>> m4 = [[0, 0], [1, 0]]
>>> symmetric(m1)True
>>> symmetric(m2)False
>>> symmetric(m3)True
>>> symmetric(m4)False
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill