Instagram
youtube
Facebook
Twitter

Python Program to Print Full Pyramid Pattern

   Python Program to Print Full Pyramid Pattern

    
   Short Description:

   This program prints a full pyramid pattern using asterisks (*).
   It takes the number of rows as input and uses nested formatting with spaces and stars to align the pattern       symmetrically.

   Explanation:

  • rows = int(input(...)) → Takes the number of rows as input.
     
  • for i in range(1, rows + 1) → Outer loop for each row.
     
  • " " * (rows - i) → Adds spaces on the left to align the stars to the right.
     
  • "*" * i → Prints i stars in each row.

num = int(input(...)) – Takes the number of rows as input from the user.
 

for i in range(1, num + 1) – Loops from 1 to num, one loop for each row.
 

" " * (num - i) – Prints spaces to center-align the pyramid. As i increases, spaces decrease.
 

"* " * i – Prints i asterisks followed by spaces, creating the pyramid shape.

Program:

um = int(input('Enter a number: '))

for i in range(1,num+1):

    print(" "* (num-i) + "* " *i)