Program to Print Matrix in Z form | Python3 program to pra square matrix in Z form ; Driver code
def diag ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if ( i == 0 ) : NEW_LINE INDENT print ( arr [ i ] [ j ] , end = " ▁ " ) NEW_LINE DEDENT elif ( i == j ) : NEW_LINE INDENT print ( arr [ i ] [ j ] , end = " ▁ " ) NEW_LINE DEDENT elif ( i == n - 1 ) : NEW_LINE INDENT print ( arr [ i ] [ j ] , end = " ▁ " ) NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ [ 4 , 5 , 6 , 8 ] , [ 1 , 2 , 3 , 1 ] , [ 7 , 8 , 9 , 4 ] , [ 1 , 8 , 7 , 5 ] ] NEW_LINE diag ( a , 4 ) NEW_LINE DEDENT