Python Program to Print Square of Right Increment Numbers Pattern

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

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

This Python program prints the square pattern of increment numbers from the right side using a while loop.

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 

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.