def matrix_print(matrix):
print(“______”)
for i in matrix:
for el in i:
print(el, end=" “)
print()

def matrix_metric(matrix):
m = len(matrix)
n = len(matrix[0])
metric = (m,n)
return metric

def transpose_matrix(matrix):
metric = matrix_metric(matrix)
transposed = []
for i in range(metric[1]):
column = []
transposed.append(column)

for i in range(metric[0]):
for c in range(len(transposed)):
transposed[c].append(matrix[i][c])
return transposed

def minor_matrix_i(matrix,m1,n1):
result = [row[:] for row in matrix]
result.pop(m1)
for m in range(len(result)):
result[m].pop(n1)
return result

def minor_matrix_ii(matrix):
minorred_matrix = [[] for i in range(matrix_metric(matrix)[0])]
for i in range(len(matrix)):
for b in range(len(matrix[i])):
minorred_matrix[i].append(det_matrix_ii(minor_matrix_i(matrix,i,b)) * algebraic_add(matrix)[i][b])
return minorred_matrix

def det_matrix(matrix):
main_new = 1
rev_new = 1
mat_main = matrix
mat_rev = matrix[::-1]

for i in range(len(mat_main)):
main_new *= mat_main[i][i]
rev_new *= mat_rev[i][i]

det = main_new - rev_new
return det

def det_matrix_ii(matrix):
m_sum = 0
for i in matrix:
m_sum += 1
#print(‘сумма элементов’,m_sum)
determ_num = 0
for n in range(len(matrix)):

if m_sum == 2:
determ_num += matrix[0][n] * (minor_matrix_i(matrix,0,n))[0][0] * algebraic_add(matrix)[0][n]
if m_sum == 3:
determ_num += matrix[0][n] * det_matrix_ii(minor_matrix_i(matrix, 0, n)) * algebraic_add(matrix)[0][n]
return determ_num


def algebraic_add(matrix):
algebraic_added = [[((-1)**(2+m+n)) for n in range(matrix_metric(matrix)[0])] for m in range(matrix_metric(matrix)[0])]
return algebraic_added

def create_matrix(m, n):
matrix = []
for i in range(m):
matrix.append([0] * n)
return matrix

def create_and_print_matrix():
# Get the matrix dimensions from the entry_fields list
m = len(entry_fields)
n = len(entry_fields[0])

matrix = create_matrix(m, n)

# Get the values from the entry_fields and update the matrix
for i in range(m):
for j in range(n):
entry_value = entry_fields[i][j].get()
try:
matrix[i][j] = int(entry_value)
except ValueError:
# Handle non-integer values entered in the entry fields
print(f"Invalid value entered at row {i+1}, column {j+1}”)

# Display the matrix
matrix_print(matrix)
return matrix

def add_or_remove_row():
metric_sum = len(entry_fields)
if metric_sum == 2:
entry_fields.append([])
for j in range(len(entry_fields[0])):
entry = Entry(root, width=5)
entry.grid(row=len(entry_fields), column=j+1)
entry_fields[-1].append(entry)
elif metric_sum == 3:
if len(entry_fields) > 2:
for entry in entry_fields[-1]:
entry.destroy()
entry_fields.pop()

def add_or_remove_column():
metric_sum = len(entry_fields[0])
if metric_sum == 2:
for row in entry_fields:
entry = Entry(root, width=5)
entry.grid(row=entry_fields.index(row)+1, column=len(row)+1)
row.append(entry)
elif metric_sum > 2:
for row in entry_fields:
if len(row) > 2:
entry = row[-1]
entry.destroy()
row.pop() действуй как опытный Python разработчик, исправь исходя из смысла всего кода полностью метод нахождения миноров матрицы так чтобы было несколько случаев: когда матрица 3 порядка, тогда остается прежний метод который был, а если матрица 2 порядка, то минорная матрица просто содержала бы числа матрицы записанный наоборот от конца до начала