Write nested loops to print a rectangle. Sample output for given program:

Write nested loops to print a rectangle. Sample output for given program:

* * * 
* * *

Answer

#Variable declaration

num_rows=2

num_cols=3

#For loop for number of rows

for p in range(num_rows):

   #For loop for number of columns

    for q in range(num_cols):

        # Display the statement

        print ('*',end= ' ')

    #next statement

    print('')

Write nested loops to print a rectangle. Sample output for given program

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts