Write a Python program to print downward triangle star pattern using for loop.
rows = int(input("Enter Downward Triangle Pattern Rows = ")) print("Downward Triangle Star Pattern") for i in range(rows, 0, -1): for j in range(0, i): print('*', end = ' ') print()
This Python example displays the downward triangle pattern of stars using a while loop.
rows = int(input("Enter Downward Triangle Pattern Rows = ")) print("Downward Triangle Star Pattern") i = rows - 1 while(i >= 0): j = 0 while(j <= i): print('*', end = ' ') j = j + 1 print() i = i - 1
Enter Downward Triangle Pattern Rows = 10
Downward Triangle Star Pattern
* * * * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
In this Python program, we used the pyDownwardTriangle function to display the downward right triangle of a given character.
def pyDownwardTriangle(rows, ch): for i in range(rows, 0, -1): for j in range(0, i): print('%c' %ch, end = ' ') print() rows = int(input("Enter Downward Triangle Star Pattern Rows = ")) ch = input("Symbol to use in Downward Triangle Pattern = " ) print("Downward Triangle Star Pattern") pyDownwardTriangle(rows, ch)
Enter Downward Triangle Star Pattern Rows = 14
Symbol to use in Downward Triangle Pattern = $
Downward Triangle Star Pattern
$ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $
$ $ $ $ $ $ $
$ $ $ $ $ $
$ $ $ $ $
$ $ $ $
$ $ $
$ $
$