Python Online Compiler
Example: Python Program to Print Hollow Square Pattern with Diagonal of Stars using loops
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python Program to Print Hollow Square Pattern with Diagonal of Stars using loops print ("-----Enter the side of a square-----") sS = int (input ()) print (end="\n") for x in range (1, sS + 1): for y in range (1, sS + 1): # It will check boundary conditions # It will check diagonal and secondary diagonal conditions if (x == 1) or (x == sS) or (y == 1) or (y == sS) or (x == y) or (y == (sS - x + 1)): print (end="*") else: print (end=" ") print (end="\n")
14
Output
Clear
ADVERTISEMENTS