Answer to Question #266199 in Python for Bayernmunich

Question #266199

Given an integer N as a starting number and K as input, write a program to print a number pyramid of K rows as shown below.


Given starting number is 10, and the number of rows in the pyramid is 5.


So the output should be:


10

11 12

13 14 15

16 17 18 19

20 21 22 23 24


1
Expert's answer
2021-11-16T05:21:23-0500
num = int(input("Enter the starting number: "))
num2 = int(input("Enter the number of rows: "))


for x in range(num2 + 1):
 for y in range(x):
     if x == y + 1:
         print(num)
 else:
     print(num, end=' ')
     num += 1

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