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

Write nested loops to print a rectangle. Example output for a 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.  Example output for a given program

Related Posts

Leave a Reply

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