;

Python Program to Print the Right Angled Triangle Number Pattern


Tutorialsrack 16/05/2020 Python

In this python program, we will learn how to print the right-angled triangle number pattern.

Here is the source code of the program to print the right-angled triangle number pattern.

Program 1: Python Program to Print the Right Angled Triangle Number Pattern Using For Loop

Python Program to Print the Right Angled Triangle Number Pattern Using For Loop
# Python Program to Print the Right Angled Triangle Number Pattern
# Using For Loop

# Take the Input From the User
rows = int(input("Enter the total Number of Rows: "))

# Print the Output
print("Right Triangle Pattern of Numbers") 
 
for i in range(1, rows + 1):
    for j in range(1, i + 1):        
        print('%d' %i, end = '  ')
    print()
Output

Enter the total Number of Rows: 5

Right Triangle Pattern of Numbers

1  

2  2  

3  3  3  

4  4  4  4  

5  5  5  5  5 

Program 2: Python Program to Print the Right Angled Triangle Number Pattern Using While Loop

Python Program to Print the Right Angled Triangle Number Pattern Using While Loop

# Python Program to Print the Right Angled Triangle Number Pattern
# Using While Loop

# Take the Input From the User
rows = int(input("Enter the total Number of Rows: "))

# Print the Output
print("Right Triangle Pattern of Numbers") 
 
i = 1
while(i <= rows):
    j = 1
    while(j <= i):        
        print('%d' %i, end = '  ')
        j = j + 1
    i = i + 1
    print()   
Output

Enter the total Number of Rows: 6

Right Triangle Pattern of Numbers

1  

2  2  

3  3  3  

4  4  4  4  

5  5  5  5  5  

6  6  6  6  6  6


Related Posts



Comments

Recent Posts
Tags