Pattern Display
* * * * *
* * * *
* * *
* *
*Implementation
n = 5
for i in range(n, 0, -1): # Outer loop for rows (decreasing order)
for j in range(i): # Inner loop for stars
print("*", end=" ")
print() # Moves to the next line
Steps
Identify the Pattern
- The number of rows (
n) determines the height of the pattern. - The first row contains
nstars (*), and each subsequent row has one less star than the previous.
Looping Strategy
- Use an outer loop to iterate through the rows (
ifromnto1). - Use an inner loop to print
istars in each row.
Printing Output
- Print stars on the same line using
end=" "to maintain spacing. - After finishing one row, move to the next line using
print().
Pattern Output
* * * * *
* * * *
* * *
* *
*
