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.

# Python Program to Print Reverse Mirrored Right Triangle Star Pattern

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 1

Python Program for Reverse Mirrored Right Triangle Star Pattern Example 2

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

# Python Program to Print Reverse Mirrored Right Triangle Star Pattern

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 Python revered mirrored right angled triangle of stars program is the same as the first example. However, we replaced the For Loop with While Loop

# Python Program to Print Reverse Mirrored Right Triangle Star Pattern

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
*  *  *  *  *  *  *  *  
   *  *  *  *  *  *  *  
      *  *  *  *  *  *  
         *  *  *  *  *  
            *  *  *  *  
               *  *  *  
                  *  *  
                     *  
>>>