Write a program to draw the half pyramid pattern in the python language of stars using the for loop. Here, you will learn how to draw the half pyramid pattern in the python language of stars using the for loop.
Take an example to print this half pyramid pattern of the stars through a python program: Star pattern programs in Python using for loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Write a program to draw the half pyramid pattern in the python language of stars using the for loop r, i, j = 0, 0, 0 # r - the number of rows print ("-----To print the half pyramid enter the number of rows-----") r = int (input ()) print (end="\n") for i in range (1, r + 1): for j in range (1, i + 1): print (end="* ") print (end="\n") |
Output:
1 2 3 4 5 6 7 8 9 10 11 12 | -----To print the half pyramid enter the number of rows----- 7 * * * * * * * * * * * * * * * * * * * * * * * * * * * * |