Skip to content
C

Problem 4: Transpose and Identity Verification

Easypython

Problem Description

Write a Python program that takes a square matrix, computes its transpose, and then verifies that multiplying the original matrix by an identity matrix of the same size returns the original matrix unchanged.

Input

A square matrix (as a nested list).

Output

The transposed matrix, and a confirmation message that multiplying by the identity matrix leaves the original unchanged.

Constraints

  • The input matrix must be square (same number of rows and columns).

Example Input

text
matrix = [[1,2],[3,4]]

Example Output

text
Transpose: [[1 3] [2 4]] Matrix unchanged after identity multiplication: True

Concepts Covered

.T (transpose), np.eye(), np.matmul(), array comparison.

Input (stdin)

Output

Run your code to see output here...