Answer to Question #294895 in Python for Durgam Ravi

Question #294895

Half pyramid with numbers but the numbers printed from below like input 1and 3


Output will be


6


5 4


3 2 1

1
Expert's answer
2022-02-08T01:16:12-0500



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