Q. Program to print the following patterns:


(a)

#######
 #    
   #   
      #  
        #
           #
#######

(b)

#######
            #
         #
       #
    #  
 #   
#######

Answer =

 

#(a)
for i in range (7) :
    for j in range (7) :
        if i == 0 or i == 6:
            print ("#", end = "")
        elif j == i :
            print ("#", end = "")
        else :
            print (" ", end = "")
    print ()

#(b)
for i in range (7) :
    for j in range (7) :
        if i == 0 or i == 6:
            print ("#", end = "")
        elif j == 7 - i :
            print ("#", end = "")
        else :
            print (" ", end = "")
    print ()

4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. நன்à®±ாக இருக்கின்றது

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post