Q. Write program that generate each of the patterns given below :-
(a)
**********
*********
********
*******
******
*****
****
***
**
*
(b)
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
(c)
**********
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
**********
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
**********
Answer
=
#(a) for i in range ( 10 ) : print ( "* " * ( 10 - i ) ) #(b) for i in range ( 10 ) : if i >= 5 : print ( " * " * 5) elif i <= 5 : for j in range(5): if j == 4 : print ( " * " * 5) else : print(" ",end="") print() #(c) for i in range (10 ): for j in range(10): if i < 5 : if j < 5 - i or j > 4 + i : print("*",end="") else : print(" ",end = "") else : if j < i - 4 or j > 13 - i : print("*" , end="") else : print(" ",end = "") print()
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )