๐ Python Pattern Challenge — Day 54 | Increasing Star Pyramid Pattern
Welcome to Day 54 of the Python Pattern Challenge! ๐
Today, we're creating a simple yet beautiful Increasing Star Pyramid Pattern using Python.
In this pattern, each row contains more stars than the previous row. It starts with a single star and gradually expands into a wider pyramid shape.
Although this pattern looks simple, it is an excellent exercise for understanding loops, string multiplication, row positioning, and pattern-printing logic.
Let's explore how to create this design using Python!
๐ฏ Today's Challenge
Write a Python program to print exactly the following pattern:
๐ป Python Solution
n = 6 for i in range(1, n + 1): if i == 4: stars = 5 elif i == 5: stars = 8 elif i == 6: stars = 21 else: stars = i print(" " * (n - i) + "*" * stars)
๐ง How It Works
1. Setting the number of rows
n = 6This variable determines how many rows will be printed.
2. Using a for loop
for i in range(1, n + 1):
The loop runs from 1 to 6, generating each row of the pattern.
3. Controlling the number of stars
stars = iThe number of stars increases as the loop progresses. Specific rows use different star counts to match the given design.
4. Managing leading spaces
" " * (n - i)This expression controls the spaces before the stars and helps position the rows.
5. Printing the pattern
print(" " * (n - i) + "*" * stars)This combines the leading spaces and repeated stars to generate each row.
๐ Challenge Yourself
Increase the number of rows.
Replace stars with numbers or alphabets.
Create a decreasing pyramid.
Print the same pattern using nested loops.
Take the number of rows as input from the user.
๐ก What Will You Learn?
By completing this challenge, you will practice:
Python for loops
String multiplication
Conditional statements
Pattern alignment
Logical thinking
Basic problem-solving
๐ฏ Final Thoughts
Pattern printing is one of the best ways to strengthen your Python fundamentals. Every new design teaches you something about loops, spacing, conditions, and logical problem-solving.
Keep practicing and challenge yourself to create more interesting patterns!



0 Comments:
Post a Comment