{"id":20185,"date":"2021-09-06T13:42:11","date_gmt":"2021-09-06T08:12:11","guid":{"rendered":"https:\/\/python-programs.com\/?p=20185"},"modified":"2021-11-22T18:36:25","modified_gmt":"2021-11-22T13:06:25","slug":"python-program-to-check-two-matrix-are-equal-or-not","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-two-matrix-are-equal-or-not\/","title":{"rendered":"Python Program to Check Two Matrix are Equal or Not"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Check Whether a Matrix is a Scalar or Not<\/a><\/p>\n

Given two matrixes and the task is to check if the given two matrixes are equal or not in Python.<\/p>\n

What is a matrix:<\/strong><\/p>\n

A matrix is a rectangular sequence of numbers divided into columns and rows. A matrix element or entry is a number that appears in a matrix.<\/p>\n

Example:<\/strong><\/p>\n

\"\"<\/p>\n

Above is the matrix which contains 5 rows and 4 columns and having elements from 1 to 20.<\/p>\n

In this order, the dimensions of a matrix indicate the number of rows and columns.<\/p>\n

Here as there are 5 rows and 4 columns it is called a 5*4 matrix.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given first matrix :\r\n5 2 0\r\n0 5 0\r\n0 0 5\r\nGiven second matrix :\r\n5 2 0\r\n0 5 0\r\n0 0 5<\/pre>\n

Output:<\/strong><\/p>\n

The given first and second matrixes are equal.<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given first matrix :\r\n3 5\r\n4 6\r\nGiven second matrix :\r\n1 2\r\n4 6<\/pre>\n

Output:<\/strong><\/p>\n

The given first and second matrixes are not equal.<\/pre>\n

Program to Check Two Matrix are Equal or Not in Python<\/h2>\n

Below are the ways to check if the given two matrixes are equal or not in Python.<\/p>\n