Instagram
youtube
Facebook
Twitter

Python Program to Print Inverted Full Pyramid Pattern

 Python Program to Print Inverted Full Pyramid Pattern


Short Description:
This Python program prints an inverted right-aligned half pyramid pattern using asterisks (*).
Each new row has more spaces and fewer stars, creating a slanting effect to the right.

Explanation (in dot points):

  • n = int(input('Enter a number: '))
    • Takes the number of rows (n) from the user.

     
  • for i in range(n, 0, -1):
    • A loop that starts from n and goes down to 1 to create decreasing rows of stars.

     
  • " " * (n - i)
    • Prints increasing spaces on the left to push the stars toward the right.

     
  • " *" * i
    • Prints i stars with a space in front of each, decreasing by one in each row.

Program:

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

for i in range(n,0,-1):

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