Skip to main content

Printing pattern A using A's and * 's

Printing pattern A using A's


We are going to write our first pattern program in python. Printing pattern A using A's is much simple in python as compare to any other programming language.

We will simply be using for loop and if-else statement for constructing a pattern A. Here is the code of how you will do that.


# Program to print a pattern A using A's
str=" "
var="A"
j=1
for i in range(10,0,-1):
    print(str*85,end="")
    print(str*i+var,end="")

    if i==10:
        continue
    elif i==4:
       print(str+var+str+var+str+var+str+var+str+var+str+var+str)
       j=j+2           else:
      print(str*j+var)
      j=j+2

Output:
           A          
         A   A
        A     A
       A       A
      A         A
     A A A A A A A 
    A             A
   A               A
  A                 A
        


Printing pattern A using *'s


Now, lets directly see the code.

# Program to print a pattern A using A's
str=" "
var="*"
j=1
for i in range(10,0,-1):
    print(str*1,end="")
    print(str*i+var,end="")

    if i==10:
        continue
    elif i==4:
       print(str+var+str+var+str+var+str+var+str+var+str+var+str)
       j=j+2
    else:
      print(str*j+var)
      j=j+2


Output:


           *         
         *   *
        *     *
       *       *
      *         *
     * * * * * * * 
    *             *
   *               *
  *                 *





Comments