Hollow Pyramid Pattern in Python

In this tutorial, we will learn how to create different types of hollow pyramid patterns using Python.

Program 1: Program to make a simple hollow pyramid in Python

Code:

Output:

Hollow Pyramid Pattern in Python

Explanation:

This hollow pyramid pattern can be made with any symbol like * or #. We have made this hollow pyramid using nested loops with the character '*'. We have printed 2 * r - 1 (r is the number of rows in the pattern) '*' characters in the last row. The number of rows can also be changed.

This hollow pyramid can be made using another method using for loops and elif conditions:

Method 2:

Code:

Output:

Hollow Pyramid Pattern in Python

Explanation:

This hollow pyramid pattern is similar to the above one, but the pattern's formation process differs. We have used elif statements to print the character '*' in the hollow pyramid.

We can make this basic hollow pyramid pattern using only while function also.

Code:

Output:

Hollow Pyramid Pattern in Python

Explanation:

This hollow pyramid is made using while loops. In this, the user takes the number of rows as input. It is a short and simple method to print the basic hollow pyramid.

There can be various patterns and modifications of the hollow pyramid.

Modifications of the hollow pyramid

1. Left half pyramid

Code:

Output:

Hollow Pyramid Pattern in Python

Explanation:

We have made a left-side half pyramid using loops. The user will give the number of rows as input.

2. Left downward half pyramid

Code:

Output:

Hollow Pyramid Pattern in Python

Explanation:

We have made a left-side downward hollow pyramid. In this, a reverse loop prints the downward left-side pyramid.

3. Downward Hollow Pyramid

Code:

Output:

Hollow Pyramid Pattern in Python

Explanation:

We have made a downward hollow pyramid in which the number of rows decreases in the loop.

We have made various types of hollow pyramid patterns using Python.