Python Program to Print a Simple Number Pattern

Write a Python program to print a simple number pattern using for loop.

rows = int(input("Enter Simple Numeber Pattern Rows = "))

print("====Printing Simple Number Pattern====")

for i in range(1, rows + 1):
    for j in range(1, i + 1):
        print(j, end = ' ')
    print()
Python Program to Print Simple Number Pattern

This example Python program displays the numbers in the right angled triangle pattern using a while loop.

rows = int(input("Enter Rows = "))

print("=======")

i = 1

while(i <= rows):
    j = 1
    while(j <= i):
        print(j, end = ' ')
        j = j + 1
    print()
    i = i + 1
Enter Rows = 9
========
1 
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 
1 2 3 4 5 6 
1 2 3 4 5 6 7 
1 2 3 4 5 6 7 8 
1 2 3 4 5 6 7 8 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.