Answer to Question #265883 in Python for Bayernmunich

Question #265883

Given an integer N, Write a program to print a pyramid of N rows as shown below.

In the example the number of rows in tbe pyramid is 5. So, the output shoyld be

. . . . 0 . . . .

. . . 0 0 0 . . .

. . 0 0 0 0 0 . .

. 0 0 0 0 0 0 0 .

0 0 0 0 0 0 0 0 0


1
Expert's answer
2021-11-14T09:21:24-0500
#Getting an input from the User
n = int(input())


#Looping through the n and creating the pyramid
for a in range(n):
 print('. ' * (n - a - 1), end='')
 print('0 ' * (2 * a + 1), end='')
 print('. ' * (n - a - 1), end='')
 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