Answer to Question #245112 in Python for Raju

Question #245112

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-10-01T01:32:55-0400
n = int(input('n: '))
k = int(input('k: '))
count = n
for i in range(k):
	count += i+1
max_len = len(str(count))
for i in range(1, k+1):
	s = ''
	for j in range(i):
		spases = max_len - len(str(n)) + 1
		s += str(n) + ' '*spases
		n += 1
	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