Floyd's Triangle in Python of Numbers using For loop
ADVERTISEMENTS
Floyd's triangle in python of numbers using for loop. In this article, you will learn how to print floyd's triangle in python of the numbers using for loop.
Source Code
# Floyd's Triangle in Python of Numbers using For loop
r, i, j, n = None, None, None, 1
# x - denotes the number of rows
print ("-----Kindly enter the number of rows to print Floyd's triangle number pattern-----")
r = int (input ())
print ("\n-----This is Floyd's triangle number pattern-----\n")
for i in range (1, r + 1):
print (end="\t")
for j in range (1, i + 1):
print (n, end="\t")
n = n + 1
print (end="\n\n")
Output
-----Kindly enter the number of rows to print Floyd's triangle number pattern-----
6
-----This is Floyd's triangle number pattern-----
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21