Print Lower Hessenberg matrix of order N | Python3 implementation of the approach ; Function to print the Upper Hessenberg matrix of order n ; If element is below sub - diagonal then pr0 ; Pra random digit for every non - zero element ; Driver code
import random NEW_LINE def UpperHessenbergMatrix ( n ) : NEW_LINE INDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( j > i + 1 ) : NEW_LINE INDENT print ( '0' , end = " ▁ " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( random . randint ( 1 , 10 ) , end = " ▁ " ) NEW_LINE DEDENT DEDENT print ( ) NEW_LINE DEDENT DEDENT n = 4 ; NEW_LINE UpperHessenbergMatrix ( n ) NEW_LINE