Python Program to Print Square of Right Decrement Numbers Pattern

Write a Python program to print square of right decrement numbers pattern using for loop.

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

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

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

This Python program prints the square pattern of right decremented numbers using a while loop.

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

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

i = rows

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

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.