Answer to Question #242280 in Python for saras

Question #242280

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-26T02:42:35-0400
N = int(input())
for i in range (1, N+1):
  for j in range(i,N):
    print(" ",end='')
  z = 0
  for j in range(1, i+1):
    if(j == 1 or i == N):
      print(str(j) + " ",end='')
    else:
      if z!=0:
        print(" ",end='')
      z=1
  for j in range(1,i):
    if(j == i-1 and j < N-1):
      print(str(j+1)+" " ,end='');
    else:
      if z!=0:
        print(" ",end='')
      z=1
  print("")

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