This Python program uses nested loops to draw the shape of digit 8 using the '*' character.
The input value (number of zeros) is used to trigger the drawing logic, though the digit itself is not directly used in the shape.
This exercise helps practice nested loops and conditional logic for rendering structured patterns.
def draw_digit_8():
rows = 7
cols = 5
for i in range(rows):
for j in range(cols):
if i == 0 or i == rows // 2 or i == rows - 1:
print("*", end="")
elif j == 0 or j == cols - 1:
print("*", end="")
else:
print(" ", end="")
print()
# Run the program
zeros = int(input("Enter number of zeros: "))
draw_digit_8()
*****
* *
* *
*****
* *
* *
*****
- The outer loop iterates over rows, and the inner loop over columns
- The top, middle, and bottom rows are filled entirely with asterisks
- In other rows, only the first and last columns contain asterisks, creating a hollow center
- This structure visually resembles the digit 8