Answer to Question #342733 in Python for Pyramid Pattern

Question #342733

Write a program to print a pyramid of N rows

+ + + + * + + + +

+ + + * * * + + +

+ + * * * * * + +


1
Expert's answer
2022-05-19T16:41:15-0400


n=int(input('Number Rows Pyramid: '))
for i in range(n):
  l=(n*n)//2-i
  r=(n*n)//2+i
  s=''
  for j in range(n*n):
    if j>=l and j<=r:
      s+='*'
    else:
      s+='+'
  print(s)

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