We are given two square matrices of same order. Check if two given matrices are identical.
Examples:
Input : A = [ [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]] B = [ [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]] Output: Matrices are identical
We have existing solution for this problem please refer C Program to check if two given matrices are identical link. In python any iterable object is comparable so we can solve this problem quickly in python with the help of List Equality.
# Function to check if two given matrices are identical def identicalMatrices(A,B):
if A = = B:
print ( 'Matrices are identical' )
else :
print ( 'Matrices are not identical' )
# Driver program if __name__ = = "__main__" :
A = [ [ 1 , 1 , 1 , 1 ],
[ 2 , 2 , 2 , 2 ],
[ 3 , 3 , 3 , 3 ],
[ 4 , 4 , 4 , 4 ]]
B = [ [ 1 , 1 , 1 , 1 ],
[ 2 , 2 , 2 , 2 ],
[ 3 , 3 , 3 , 3 ],
[ 4 , 4 , 4 , 4 ]]
identicalMatrices(A,B)

Output:
Matrices are identical
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
 Program to check if two given matrices are identical
 Python  Check if two list of tuples are identical
 Check the equality of integer division and math.floor() of Regular division in Python
 Python  Check if all elements in a list are identical
 Python  Check if tuple and list are identical
 Python  Check whether two lists are circularly identical
 Python  Check if two lists are identical
 Check if the given two matrices are mirror images of one another
 Program to concatenate two given Matrices of same size
 Python program to add two Matrices
 Python program to add two matrices
 Python program to multiply two matrices
 Program for addition of two matrices
 Java Program to Multiply two Matrices of any size
 Java Program to Add two Matrices
 Program to multiply two matrices
 Python  Identical Consecutive Grouping in list
 Count pairs from two sorted matrices with given sum
 Multiplication of two Matrices in Single line using Numpy in Python
 Kronecker Product of two matrices
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.