Instagram
youtube
Facebook
Twitter

Python Program to Print Floyd's Triangle

A Python Program to Print Floyd's Triangle?

Code Explanation:

● A variable num is initialized to 1 to start counting.

● Outer loop runs from 1 to 4 to represent rows.

● Inner loop prints i numbers in each row.

● Inside the inner loop, num is printed and then incremented.

print() after the inner loop moves to the next line.

Program:

num = 1

for i in range(1, 5):

    for j in range(i):

        print(num, end="")

        num += 1

    print()