DEV Community

Keerti Sadana S
Keerti Sadana S

Posted on

PYTHON - ALPHABET PATTERNS

Square:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 7 or col == 7:
            print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * * * 
*           * 
*           * 
*           * 
*           * 
*           * 
* * * * * * * 
Enter fullscreen mode Exit fullscreen mode

Letter A:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4  or col == 7 :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7)) :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
*           * 
*           * 
* * * * * * * 
*           * 
*           * 
Enter fullscreen mode Exit fullscreen mode

Letter B:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 or row == 7 or col == 7 :
            if (row == 1 and (col == 7)) or (row == 7 and (col == 7)) or (row == 4 and col == 7):
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * *   
*           * 
*           * 
* * * * * * 
*           * 
*           * 
* * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter C:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 7 :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7)) :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
*             
*             
*             
*             
*             
  * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter D:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 7 or col == 7 :
            if not (row==col) :
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * * 
*           * 
*           * 
*           * 
*           * 
*           * 
* * * * * * 
Enter fullscreen mode Exit fullscreen mode

Letter E:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 or row == 7  :
            if (row == 1 and (col == 7)) or (row == 7 and (col == 7)) or col == 7:
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * *   
*             
*             
* * * * * *   
*             
*             
* * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter F:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 :
            print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * * * 
*             
*             
* * * * * * * 
*             
*             
*             
Enter fullscreen mode Exit fullscreen mode

Letter G:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 or col == 7 or row == 7 :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7) or (row == 2 or row == 3) and col == 7) or (row == 4 and col == 2) :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
*             
*             
*   * * * * * 
*           * 
*           * 
  * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter H:

for row in range(1,8):
    for col in range (1,8):
        if col == 1 or row == 4 or col == 7  :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7)) :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

*           * 
*           * 
* * * * * * * 
*           * 
*           * 
Enter fullscreen mode Exit fullscreen mode

Letter I:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 4  or row == 7  :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7)) :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
      *       
      *       
      *       
      *       
      *       
  * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter J:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 4  or row == 7  :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7)) or (row == 7 and (col == 4 or col==5 or col == 6)) :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
      *       
      *       
      *       
      *       
      *       
  * *         
Enter fullscreen mode Exit fullscreen mode

Letter L:

for row in range(1,8):
    for col in range (1,8):
        if row == 7 or col == 1    :
            if (row == 1 and ( col == 7)) or (row == 7 and ( col == 7))  :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

*             
*             
*             
*             
*             
*             
* * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter M:

for row in range(1,8):
    for col in range(1,8):
        if col == 1 or col == 7 or row == col or row+col==8:
            if (row == 5 and (col == 3 or col == 5)) or (row == 6 and (col == 2 or col == 6)):
                print(" ", end=' ')
            else:
                print('*',end=' ')
        else:
            print(" ", end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

*           * 
* *       * * 
*   *   *   * 
*     *     * 
*           * 
*           * 
*           * 
Enter fullscreen mode Exit fullscreen mode

Letter N:

for row in range(1,8):
    for col in range(1,8):
        if col == 1 or col == 7 or row == col or row+col==8:
            if (row == 5 and (col == 3 )) or (row == 6 and (col == 2 )) or (row == 3 and col == 5) or (row == 2 and col == 6):
                print(" ", end=' ')
            else:
                print('*',end=' ')
        else:
            print(" ", end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

*           * 
* *         * 
*   *       * 
*     *     * 
*       *   * 
*         * * 
*           * 
Enter fullscreen mode Exit fullscreen mode

Letter O:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 7 or col == 7 :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7)):
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
*           * 
*           * 
*           * 
*           * 
*           * 
  * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter P:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 or col == 7   :
            if (row == 1 and ( col == 7)) or ((row == 4 or row == 7) and (col == 7)) or ((row == 5 or row == 6) and col == 7)  :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * *   
*           * 
*           * 
* * * * * *   
*             
*             
*             
Enter fullscreen mode Exit fullscreen mode

Letter R:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 or col == 7 or row == col or row+col==8  :
            if (row == 1 and ( col == 7)) or ((row == 4 ) and (col == 7)) or ((row == 5 or row == 6) and col == 7) or (row == 5 and (col == 3 )) or (row == 6 and (col == 2 )) or (row == 3 and col == 5) or (row == 2 and col == 6) or (row == 2 and col == 2) or ( row == 3 and col == 3):
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * *   
*           * 
*           * 
* * * * * *   
*       *     
*         *   
*           * 
Enter fullscreen mode Exit fullscreen mode

Letter S:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 or col == 7 or row == 7  :
            if (row == 1 and (col == 1 or col == 7)) or ((row == 7 or row == 4) and (col == 1 or col == 7)) or ((row == 2 or row == 3) and col == 7) or ((row == 5 or row == 6 ) and col == 1)  :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
*             
*             
  * * * * *   
            * 
            * 
  * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter T:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 4    :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7))  :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
      *       
      *       
      *       
      *       
      *       
      *       
Enter fullscreen mode Exit fullscreen mode

Letter U:

for row in range(1,8):
    for col in range (1,8):
        if col == 1  or col == 7 or row == 7  :
            if (row == 7 and (col == 1 or col == 7))   :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

*           * 
*           * 
*           * 
*           * 
*           * 
*           * 
  * * * * *   
Enter fullscreen mode Exit fullscreen mode

Letter V:

for row in range(1,8):
    for col in range(1,8):
        if   row == col or row+col==8:
            if (row == 5 and (col == 3 or col == 5)) or (row == 6 and (col == 2 or col == 6) or row == 7 ):
                print(" ", end=' ')
            else:
                print('*',end=' ')
        else:
            print(" ", end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

*           * 
  *       *   
    *   *     
      *       
Enter fullscreen mode Exit fullscreen mode

Letter X:

for row in range(1,8):
    for col in range(1,8):
        if  row == col or row+col==8:  
            print("*", end=' ')
        else:
            print(" ", end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

*           * 
  *       *   
    *   *     
      *       
    *   *     
  *       *   
*           * 
Enter fullscreen mode Exit fullscreen mode

Letter Y:

for row in range(1,8):
    for col in range(1,8):
        if   col == 4 or row == col or row+col==8:
            if (row == 5 and (col == 3 or col == 5)) or (row == 6 and (col == 2 or col == 6) or row == 7 or (row == 1 and col == 4) or (row == 2 and col == 4) or (row == 3 and col ==4)):
                print(" ", end=' ')
            else:
                print('*',end=' ')
        else:
            print(" ", end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

*           * 
  *       *   
    *   *     
      *       
      *       
      *       

Enter fullscreen mode Exit fullscreen mode

Letter Z:

for row in range(1,8):
    for col in range(1,8):
        if row == 1 or row == 7  or row+col==8:
            print('*',end=' ')
        else:
            print(" ", end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * * * 
          *   
        *     
      *       
    *         
  *           
* * * * * * * 
Enter fullscreen mode Exit fullscreen mode

** Number 3:**

for row in range(1,8):
    for col in range (1,8):
        if row == 1  or row == 4 or row == 7 or col == 7 :
            if (row == 1 and (col == 7)) or (row == 7 and (col == 7)):
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * *   
            * 
            * 
* * * * * * * 
            * 
            * 
* * * * * *   
Enter fullscreen mode Exit fullscreen mode

Number 6:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 or col == 7 or row == 7 :
            if (row == 1 and (col == 1 or col == 7)) or (row == 7 and (col == 1 or col == 7) or (row == 2 or row == 3) and col == 7) :
                print(' ',end = ' ')
            else:
                print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

  * * * * *   
*             
*             
* * * * * * * 
*           * 
*           * 
  * * * * *   
Enter fullscreen mode Exit fullscreen mode

Number 8:

for row in range(1,8):
    for col in range (1,8):
        if row == 1 or col == 1 or row == 4 or row == 7 or col == 7 :
            print('*',end=' ')
        else:
            print(' ',end=' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

* * * * * * * 
*           * 
*           * 
* * * * * * * 
*           * 
*           * 
* * * * * * * 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)