๐ Python Pattern Challenge — Day 36 | Number Mirror Pyramid
Welcome to Day 36 of the Python Pattern Challenge! ๐
Today, we're creating a beautiful Number Mirror Pyramid using Python. This pattern combines increasing and decreasing number sequences to create a symmetrical design that becomes smaller with each row.
It's a great exercise for beginners who want to improve their understanding of loops, number sequences, spacing, and logical thinking.
๐ฏ Today's Challenge
Write a Python program to print exactly this pattern:
๐ป Python Solution
n = 5 for i in range(n, 0, -1): print(" " * (n - i), end="") for j in range(1, i + 1): print(j, end=" ") for j in range(i - 1, 0, -1): print(j, end=" ") print()
๐ง How It Works
Creating the rows
for i in range(n, 0, -1):This loop starts at 5 and decreases to 1, creating five rows of decreasing width.
Adding spaces
print(" " * (n - i), end="")This adds leading spaces to shift each row toward the right and form a triangular shape.
Printing increasing numbers
for j in range(1, i + 1):This prints numbers from 1 up to the current row number.
Printing decreasing numbers
for j in range(i - 1, 0, -1):This prints the numbers in reverse order without repeating the largest number.
For example, when i = 5, the row becomes:
1 2 3 4 5 4 3 2 1๐ Challenge Yourself
Increase the starting number to 7.
Create the same pattern using a while loop.
Replace numbers with alphabets.
Print the pattern in reverse order.
Create a full diamond by adding an expanding lower section.
Take the maximum number from the user as input.
Share your solution in the comments! ๐
36 Days. 36 Patterns. Stronger Python Logic. ๐๐ฅ
Learn • Practice • Grow with CLCODING



0 Comments:
Post a Comment