Python - Hình Chữ Nhật

Python - Hình Chữ Nhật

 

Question:


Python

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


 


Answer:




 

EDITABLE CODE:

#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('')

Previous Post
First

post written by:

Related Posts

0 Comments: