Python 打印右侧递增数字的平方图案程序

编写一个 Python 程序,使用 for 循环打印右侧递增数字的平方图案。

rows = int(input("Enter Square of Right Increment Numbers Rows = "))

print("====The Square of Right Incremented Numbers Pattern====")

for i in range(1, rows + 1):
    for j in range(1, rows - i + 1):
        print(1, end = ' ')
    for k in range(1, i + 1):
        print(i, end = ' ')
    print()
Python Program to Print Square of Right Increment Numbers Pattern

这个 Python 程序使用 while 循环从右侧打印递增数字的平方图案。

rows = int(input("Enter Square of Right Increment Numbers Rows = "))

print("====The Square of Right Incremented Numbers Pattern====")
i = 1

while(i <= rows):
    j = 1
    while(j <= rows - i):
        print(1, end = ' ')
        j = j + 1
    k = 1
    while(k <= i):
        print(i, end = ' ')
        k = k + 1
    print()
    i = i + 1
Enter Square of Right Increment Numbers Rows = 9
====The Square of Right Incremented Numbers Pattern====
1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 2 2 
1 1 1 1 1 1 3 3 3 
1 1 1 1 1 4 4 4 4 
1 1 1 1 5 5 5 5 5 
1 1 1 6 6 6 6 6 6 
1 1 7 7 7 7 7 7 7 
1 8 8 8 8 8 8 8 8 
9 9 9 9 9 9 9 9 9