Pattern 1: Pyramid

# Python Code for Pattern 1 n = 5 for i in range(n): for j in range(i + 1): print("*", end=" ") print()
Output:
* 
* * 
* * * 
* * * * 
* * * * * 
                    

Pattern 2: Diamond

# Python Code for Pattern 2 (Diamond) n = 5 for i in range(n): print(" " * (n - i - 1) + "*" * (2 * i + 1)) for i in range(n - 2, -1, -1): print(" " * (n - i - 1) + "*" * (2 * i + 1))
Output:
    *    
   ***   
  *****  
 ******* 
*********
 ******* 
  *****  
   ***   
    *    
                    

Pattern 3: Hollow Square

# Python Code for Pattern 3 (Hollow Square) n = 5 for i in range(n): for j in range(n): if i == 0 or i == n - 1 or j == 0 or j == n - 1: print("*", end=" ") else: print(" ", end=" ") print()
Output:
* * * * * 
*       * 
*       * 
*       * 
* * * * *