-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprac11.py
More file actions
45 lines (36 loc) · 1.17 KB
/
prac11.py
File metadata and controls
45 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 14 22:44:19 2019
@author: rounak
"""
#toeplitz matrix check function
def checkToeplitz(matrix, m, n):
for i in range(m-1):
for j in range(n-1):
if matrix[i][j] != matrix[i+1][j+1]:
return False
return True
#matrix display function
def display_mat(matrix, m, n):
for i in range(m):
print(matrix[i])
#driver code
if "__name__" == "__main__":
#input of row and column number
m = int( input("Enter the number of rows: "))
n = int( input("Enter the number of columns: "))
#initializing the 2-d array
matrix = [[0 for j in range(n)] for i in range(m)]
#taking input in the 2-d array
for i in range(m):
for j in range(n):
print(str(i+1) + " row, " + str(j+1) + " column: ", end = "")
matrix[i][j] = int(input())
#printing th matrix
print("The entered matrix is:")
display_mat(matrix, m, n)
#calling the cehcking function
if checkToeplitz(matrix, m, n):
print("The matrix is a toeplitx matrix.")
else:
print("The matrix is not a toeplitx matrix.")