def matTransposed(mat):
    """Return the transposed of a nxn matrix.

    >>> matTransposed(((1, 2), (3, 4)))
    ((1, 3), (2, 4))"""
    dim = len(mat)
    return tuple( tuple( mat[i][j]
                         for i in range(dim) )
                  for j in range(dim) )