Hollow Square of Stars Printing Python Program – This program will print a hollow square of stars in Python programming language.

Here’s a Python program to print a hollow square:
n = 5
for i in range(n):
if i == 0 or i == n - 1:
print('*' * n)
else:
print('*' + ' ' * (n - 2) + '*')
In this program, we use a loop to iterate through each row of the square. We have a conditional if else statement to know whether the current row is the first or last row. If it is, we print a full line of asterisks (*). Otherwise, we print an asterisk (*) followed by spaces ( ) to create the hollow portion of the square and a star at end.
![]()