Python programs for printing pyramid patterns

Patterns can be printed in python using simple for loops. First outer loop is used to handle number of rows and Inner nested loop is used to handle the number of columns. Manipulating the print statements, different number patterns, alphabet patterns or star patterns can be printed. 
Some of the Patterns are shown in this article. 

Python is a versatile language that can be used for a wide range of programming tasks, including printing pyramid patterns. These patterns can be created using loops and other programming constructs that are available in Python. Here are a few examples of Python programs for printing pyramid patterns:

    1. Printing a pyramid of asterisks: 

 

rows = int(input("Enter the number of rows: "))
for i in range(0, rows):
    for j in range(0, rows-i-1):
        print(end=" ")
    for j in range(0, i+1):
        print("*", end=" ")
    print()

 

    1. Printing a hollow pyramid of asterisks: 

 

rows = int(input("Enter the number of rows: "))
for i in range(0, rows):
    for j in range(0, rows-i-1):
        print(end=" ")
    for j in range(0, i+1):
        if i == rows-1 or j == 0 or j == i:
            print("*", end=" ")
        else:
            print(" ", end=" ")
    print()
    1. Printing a pyramid of numbers: 

 

rows = int(input("Enter the number of rows: "))
for i in range(0, rows):
    for j in range(0, rows-i-1):
        print(end=" ")
    for j in range(0, i+1):
        print(j+1, end=" ")
    print()
    1. Printing a hollow pyramid of numbers:

 

rows = int(input("Enter the number of rows: "))
for i in range(0, rows):
    for j in range(0, rows-i-1):
        print(end=" ")
    for j in range(0, i+1):
        if i == rows-1 or j == 0 or j == i:
            print(j+1, end=" ")
        else:
            print(" ", end=" ")
    print()

These are just a few examples of the many pyramid patterns that can be printed using Python. By experimenting with different values and combinations of loops, it is possible to create a wide range of interesting and complex patterns.

Submit Your Programming Assignment Details