Reverse Pyramid Pattern in Python

Hello everyone, welcome back to programminginpython.com! As a part of the series on pattern programming, Here I will explain to you how to print a reverse pyramid pattern or a reverse triangle pattern in Python. In one of my earlier post, I have explained how to print a pyramid pattern, now I will explain how to print a reverse pyramid pattern in python.

Tip: Join Codecademy. The easiest way to learn to code. Codecademy is the easiest way to learn how to code. It’s interactive, fun, and you can do it with your friends.

Program on Github

You can also watch the video on YouTube here.

Task

Python Program to print a Reverse Pyramid Pattern or Reverse Triangle Pattern.

Approach

  • Read an input integer for asking the range of the triangle using  input()
  • Run 3 for loops, one main for row looping, and the other 2 sub-loops for column looping, in the first loop, loop through the range of the triangle for row looping.
  • In the second loop, loop through the value of the range from max to 1, this is to print space
  • In the third loop, loop through the value of range to max and print *

Print Reverse Pyramid Pattern – Code Visualization

Program

Output

Reverse Pyramid Pattern || programminginpython.com
Reverse Pyramid Pattern || programminginpython.com
Reverse Pyramid Pattern || programminginpython.com
Reverse Pyramid Pattern || programminginpython.com

Program on Github

That is it for this tutorial. Also, feel free to look at programs on other patterns or some algorithms implementation in python here or look at all of the posts here.

Course Suggestion

The Complete Web Developer Course.
Learn Web Development by building 25 websites and mobile apps using HTML, CSS, Javascript, PHP, Python, MySQL & more!
Course: The Complete Web Developer Course 2.0

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.