Thursday, December 10, 2020

pattern printing using for loop in python

 


number_of_stars=10


for i in range(5):

    

    for j in range(number_of_stars):

        if i<=j:

            print("",end=' ')

    for j in range(number_of_stars):

        if i>=j:

            print("*",end=' ')

    print()

for i in range(number_of_stars):

    for j in range(number_of_stars):

        if i>=j:

            print("",end=' ')

    for j in range(number_of_stars):

        if i<=j:

            if i<=4:

                print("*",end=' ')

    print()



     * 

         * * 

        * * * 

       * * * * 

      * * * * * 

 * * * * * * * * * * 

  * * * * * * * * * 

   * * * * * * * * 

    * * * * * * * 

     * * * * * * 

No comments:

Post a Comment

python class topic video