Python Program to Print Reverse Mirrored Right Triangle Star Pattern

Write a Python Program to Print Reverse Mirrored Right Triangle Star Pattern using For Loop and While Loop with an example.

Python Program to Print Reverse Mirrored Right Triangle Star Pattern using For Loop

This Python program allows user to enter the total number of rows. Next, we used Python Nested For Loop to print reversed mirrored right angled triangle of stars pattern from the user specified maximum value (rows) to 1.

rows = int(input("Please Enter the Total Number of Rows  : "))

print("Reverse Mirrored Right Triangle Star Pattern")
for i in range(1, rows + 1):
for j in range(1, rows + 1):
if(j < i):
print(' ', end = ' ')
else:
print('*', end = ' ')
print()
Python Program to Print Reverse Mirrored Right Triangle Star Pattern

Python Program for Reverse Mirrored Right Triangle Star Pattern Example 2

This Python program allows user to enter their own character. Next, it prints the reversed mirror right angled triangle of the user-specified character.

rows = int(input("Please Enter the Total Number of Rows  : "))
ch = input("Please Enter any Character : ")

print("Reverse Mirrored Right Triangle Star Pattern")
for i in range(1, rows + 1):
for j in range(1, rows + 1):
if(j < i):
print(' ', end = ' ')
else:
print('%c' %ch, end = ' ')
print()
Please Enter the Total Number of Rows  : 10
Please Enter any Character  : @
Reverse Mirrored Right Triangle Star Pattern
@  @  @  @  @  @  @  @  @  @  
   @  @  @  @  @  @  @  @  @  
      @  @  @  @  @  @  @  @  
         @  @  @  @  @  @  @  
            @  @  @  @  @  @  
               @  @  @  @  @  
                  @  @  @  @  
                     @  @  @  
                        @  @  
                           @  
>>> 

Python Program to Display Reversed Mirrored Right Triangle Star Pattern using While Loop

This revered mirrored right angled triangle of stars program is the same as the first example. However, in this Python example, we replaced the For Loop with While Loop

rows = int(input("Please Enter the Total Number of Rows  : "))

print("Reverse Mirrored Right Triangle Star Pattern")
i = 1
while(i <= rows):
j = 1
while(j <= rows):
if(j < i):
print(' ', end = ' ')
else:
print('*', end = ' ')
j = j + 1
i = i + 1
print()
Please Enter the Total Number of Rows  : 8
Reverse Mirrored Right Triangle Star Pattern
*  *  *  *  *  *  *  *  
   *  *  *  *  *  *  *  
      *  *  *  *  *  *  
         *  *  *  *  *  
            *  *  *  *  
               *  *  *  
                  *  *  
                     *  
>>>