This Python program reads a 1×1 matrix A from input and stores its transpose in matrix B.
In the transpose, the relation B[i][j] = A[j][i] holds.
def transpose_matrix(A: list[list[int]]) -> list[list[int]]:
rows = len(A)
cols = len(A[0])
B = [[0 for _ in range(rows)] for _ in range(cols)]
for i in range(rows):
for j in range(cols):
B[j][i] = A[i][j]
return B
# Read input from user
value = int(input("Enter value for A[0][0]: "))
A = [[value]]
B = transpose_matrix(A)
print(f"Matrix A: {A}")
print(f"Transpose B: {B}")
Enter value for A[0][0]: 7
Matrix A: [[7]]
Transpose B: [[7]]