Question #242286

Half Pyramid - 3

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.


Expert's answer

def halfPyramid(row,col):
    for x in range(0, col):
        for y in range(0, x + 1):
            print(row, end=' ')
            row += 1
        print(" ")


print("Sample Input 1")
print(10)
print(5)
print("Sample Ouput 1")
halfPyramid(10,5)


print("\nSample Input 2")
print(1)
print(3)
print("Sample Ouput 2")
halfPyramid(1,3)

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!

LATEST TUTORIALS
APPROVED BY CLIENTS