Floyd's Triangle - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Friday, June 19, 2020

Floyd's Triangle

python-mini

Question

To Print Floyd's Triangle using numbers.

Sample TestCaseExpected Output

Enter number of rows : 3                                                                               

                                                                                                                       2 3 

                                                                                                                       4 5 6 

Answer


  rows=int(input("Enter number of rows : "))
number=1
print("Floyd's Triangle")
for i in range(1,rows+1):
    for j in range(1,i+1):
        print(number,end=" ")
        number+=1
    print()



No comments:

Post a Comment