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.
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?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments