How to make a Half Pyramid
Pyramid are sequences of characters shaped in form of Equilateral Triangle which is equal from all sides.
Half Pyramid one sided part of Pyramid and it is in shape of a Right Angle Triangle.
So let’s jump to the code and see how we can do it.
Method 1 (Single Loop)
def half_pyramid(rows): for i in range(1, rows+1): print(i * ("*"), end = "\n")
half_pyramid(7)
Method 2 (Multi Loop)
def half_pyramid(rows): for i in range(1, rows): for j in range(i): print('*', end="") print()
half_pyramid(7)
Method 3 (Recursion)
def half_pyramid(rows): if rows > 0: half_pyramid(rows - 1)
print("*" * rows)
half_pyramid(7)