Answer to Question #221739 in Python for Hari nadh babu

Question #221739

Half Pyramid - 4


This Program name is Half Pyramid - 4 Write a Python program to Half Pyramid - 4


The below link contains Half Pyramid - 4 question, explanation and test cases


https://drive.google.com/file/d/1XUDbl1HqlrQ-ORm60rT22WK8MDmKxrPz/view?usp=sharing


We need exact output when the code was run

1
Expert's answer
2021-08-05T03:02:08-0400
N = int(input('First input: '))
K = int(input('Second input: '))
init = 0
for k in range(1,K+1):
  init = init+k
maxi = N + (init-1)
for i in range(K):
  if i == 0:
    print(maxi,end=' ')
  else:
    for j in range(1,i+2):
      maxi = maxi-1
      print(maxi,end=' ')
  print('')

First input: 10
Second input: 5
24 
23 22 
21 20 19 
18 17 16 15 
14 13 12 11 10 

First input: 1
Second input: 3
6 
5 4 
3 2 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