Python Program to Print (Generate) Cross Star Pattern

This program prints Cross like pattern made of star in Python programming language.

To generate cross pattern we first read value of n from user. After reading n we generate cross (x) pattern having n stars on each segment in the pattern.

Python Source Code: Cross Pattern


# Creating cross pattern of stars

# Reading number of row
n = int(input('Enter the value of n: '))

for i in range(1,2*n):
    for j in range(1,2*n):
        if i==j or i+j==2*n:
            print('*', end='')
        else:
            print(' ', end='')
    print()

Output: Cross Pattern

Output of generated cross pattern is:

Enter the value of n: 10

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