Answer to Question #243970 in Python for Raju

Question #243970

Hollow Full Pyramid - 2

Given the number of rows N, write a program to print the hallow full pyramid pattern similar to the pattern shown below.

   1 

   1 2 

  1   3 

1     4 

1 2 3 4 5


1
Expert's answer
2021-09-29T18:49:00-0400


def display( n) :
    k = 0
    m2=1
    for i in range(1,n+1) :
        m1=0
        
        for j in range(i,n) :
            print(' ', end='')
        while (k != (2 * i - 1)) :
            # if (k == 0 or k == 2 * i - 2) :
            if (k == 0) :
                m1+=1
                print(m1, end='')
            elif (k == 2 * i - 2) :
                m2+=1
                print(m2, end='')
            else :
                print(' ', end ='')
            k = k + 1
        k = 0;
        print ("") 
    for i in range(1, 2 * n ) :
        print (i, end = '')


n = 4
display(n)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS