Write a Python Program to Print Hollow Right Triangle Star Pattern using for loop. The nested for loops iterate from 1 to rows and i and if condition check for the outline values and print those stars.
# Python Program to Print Hollow Right Triangle Star Pattern rows = int(input("Enter Hollow Right Triangle Pattern Rows = ")) print("Hollow Right Triangle Star Pattern") for i in range(1, rows + 1): for j in range(1, i + 1): if i == 1 or i == rows or j == 1 or j == i: print('*', end = '') else: print(' ', end = '') print()
This Python Program prints the Hollow Right Triangle Star Pattern using a while loop.
rows = int(input("Enter Hollow Right Triangle Pattern Rows = ")) print("Hollow Right Triangle Star Pattern") i = 1 while(i <= rows): j = 1 while(j <= i): if i == 1 or i == rows or j == 1 or j == i: print('*', end = '') else: print(' ', end = '') j = j + 1 i = i + 1 print()
Enter Hollow Right Triangle Pattern Rows = 12
Hollow Right Triangle Star Pattern
*
**
* *
* *
* *
* *
* *
* *
* *
* *
* *
************
>>>
In this Python example, we created a hollowRightTriangle function to print the Hollow Right angled triangle Pattern. It replaces the hollow Hollow Right Triangle star with a given symbol.
def hollowRightTriangle(rows, ch): for i in range(1, rows + 1): for j in range(1, i + 1): if i == 1 or i == rows or j == 1 or j == i: print('%c' %ch, end = '') else: print(' ', end = '') print() rows = int(input("Enter Hollow Right Triangle Pattern Rows = ")) ch = input("Symbol to use in Hollow Right Triangle = ") print("Hollow Right Triangle Star Pattern") hollowRightTriangle(rows, ch)
Enter Hollow Right Triangle Pattern Rows = 15
Symbol to use in Hollow Right Triangle = $
Hollow Right Triangle Star Pattern
$
$$
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$$$$$$$$$$$$$$$
>>>