Python Program to Print Pyramid Star Pattern

Write a Python Program to Print Pyramid Star Pattern using a for loop. This Python example uses multiple for loop nested inside a for loop to print the Pyramid pattern.

# Python Program to Print Pyramid Star Pattern
 
rows = int(input("Enter Pyramid Pattern Rows = "))

print("Pyramid Star Pattern") 

for i in range(0, rows):
    for j in range(0, rows - i - 1):
        print(end = ' ')
    for k in range(0, i + 1):
        print('*', end = ' ')
    print()
Python Program to Print Pyramid Star Pattern 1

In this Python example, we twisted the for loops to print the Pyramid star pattern.

# Python Program to Print Pyramid Star Pattern
 
rows = int(input("Enter Pyramid Pattern Rows = "))

print("Pyramid Star Pattern") 

for i in range(1, rows + 1):
    for j in range(1, rows - i + 1):
        print(' ', end = '')
    for k in range(1, (2 * i)):
        print('*', end = '')
    print()
Enter Pyramid Pattern Rows = 15
Pyramid Star Pattern
              *
             ***
            *****
           *******
          *********
         ***********
        *************
       ***************
      *****************
     *******************
    *********************
   ***********************
  *************************
 ***************************
*****************************
>>> 

In this Python Program, the pyramidStar function prints the Pyramid Pattern of a given symbol.

# Python Program to Print Pyramid Star Pattern

def pyramidStar(rows, ch):
    for i in range(0, rows):
        for j in range(0, rows - i - 1):
            print(end = ' ')
        for k in range(0, i + 1):
            print('%c' %ch, end = ' ')
        print()


rows = int(input("Enter Pyramid Pattern Rows = "))

ch = input("Symbol to Print in Pyramid Pattern = ")

print("Pyramid Star Pattern") 
pyramidStar(rows, ch)
Enter Pyramid Pattern Rows = 12
Symbol to Print in Pyramid Pattern = #
Pyramid Star Pattern
           # 
          # # 
         # # # 
        # # # # 
       # # # # # 
      # # # # # # 
     # # # # # # # 
    # # # # # # # # 
   # # # # # # # # # 
  # # # # # # # # # # 
 # # # # # # # # # # # 
# # # # # # # # # # # # 
>>>