Answer to Question #242287 in Python for Raju

Question #242287

Half Pyramid - 4

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.


1
Expert's answer
2021-09-26T02:42:54-0400
N = int(input())
K = int(input())
L = 0
for k in range(1,K+1):
  L +=k
maxValue = N + (L-1)
for i in range(K):
  if i == 0:
    print(maxValue,end=' ')
  else:
    for j in range(1,i+2):
      maxValue -=1
      print(maxValue,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