Python 打印倒直角三角形星形图案的程序

编写一个 Python 程序,通过实际示例打印倒直角三角形星形图案。

Python 使用 While 循环打印倒直角三角形星形图案的程序

此 Python 程序允许用户输入总行数。接下来,我们使用 Python 嵌套 While 循环 来打印倒直角三角形的星形。

# Python Program to Print Inverted Right Triangle Star Pattern
 
rows = int(input("Please Enter the total Number of Rows  : "))
 
print("Inverted Right Angle Triangle of Stars") 
i = rows
while(i > 0):
    j = i
    while(j > 0):      
        print('* ', end = '  ')
        j = j - 1
    i = i - 1
    print()
Python Program to Print Inverted Right Triangle Star Pattern

Python 打印倒直角星形三角形的程序 示例 2

Python 程序 允许用户输入他/她自己的字符。接下来,它会打印用户指定的字符的倒直角三角形。

# Python Program to Print Inverted Right Triangle Star Pattern
 
rows = int(input("Please Enter the total Number of Rows  : "))
ch = input("Please Enter any Character  : ")
 
print("Inverted Right Angle Triangle of Stars") 
i = rows
while(i > 0):
    j = i
    while(j > 0):      
        print('%c' %ch, end = '  ')
        j = j - 1
    i = i - 1
    print()
Please Enter the total Number of Rows  : 15
Please Enter any Character  : $
Inverted Right Angle Triangle of Stars
$  $  $  $  $  $  $  $  $  $  $  $  $  $  $  
$  $  $  $  $  $  $  $  $  $  $  $  $  $  
$  $  $  $  $  $  $  $  $  $  $  $  $  
$  $  $  $  $  $  $  $  $  $  $  $  
$  $  $  $  $  $  $  $  $  $  $  
$  $  $  $  $  $  $  $  $  $  
$  $  $  $  $  $  $  $  $  
$  $  $  $  $  $  $  $  
$  $  $  $  $  $  $  
$  $  $  $  $  $  
$  $  $  $  $  
$  $  $  $  
$  $  $  
$  $  
$  
>>>