+1 vote
in Python by

Print the following pattern:

0

0 1

0 1 2

0 1 2 3

0 1 2 3 4

1 Answer

0 votes
by

Below is the Code to draw the pattern in python

def pattern_3(num): 

      

    # initialising starting number  

    number = 1

    # outer loop always handles the number of rows 

    # let us use the inner loop to control the number 

   

    for i in range(0, num): 

      

        # re assigning number after every iteration

        # ensure the column starts from 0

        number = 0

      

        # inner loop to handle number of columns 

        for j in range(0, i+1): 

          

                # printing number 

            print(number, end=" ") 

          

            # increment number column wise 

            number = number + 1

        # ending line after each row 

        print("\r") 

 

num = int(input("Enter the number of rows in pattern: "))

pattern_3(num)

Related questions

+1 vote
asked Feb 15, 2021 in Python by SakshiSharma
0 votes
asked Jan 18, 2021 in Python by SakshiSharma
...