Tuesday, 1 December 2026

๐Ÿ Python Pattern Challenge — Day 56

 


๐Ÿ Python Pattern Challenge — Day 56 | Number Diamond Pyramid Pattern

Welcome to Day 56 of the Python Pattern Challenge! ๐Ÿš€

Today, we're creating a beautiful Number Diamond Pyramid Pattern using Python.

This pattern starts with the number 1 at the top and gradually expands toward the center. Each row contains increasing numbers followed by decreasing numbers, creating a symmetrical diamond shape.

After reaching the middle row, the pattern reverses and gradually shrinks until it ends with 1.

This challenge is perfect for improving your understanding of nested loops, number sequences, spacing, and mathematical logic.

๐ŸŽฏ Today's Challenge

Write a Python program to print exactly the following pattern:


๐Ÿ’ป Python Solution

n = 5 for i in range(1, n + 1): row = list(range(i, 2 * i)) row += list(range(2 * i - 2, i - 1, -1)) print(" " * (n - i) + " ".join(map(str, row))) for i in range(n - 1, 0, -1): row = list(range(i, 2 * i)) row += list(range(2 * i - 2, i - 1, -1)) print(" " * (n - i) + " ".join(map(str, row)))






๐Ÿง  Understanding the Logic

1. Define the pattern size

n = 5


This variable determines the maximum number of levels in the upper half of the diamond.

2. Generate increasing numbers

row = list(range(i, 2 * i))

This generates an increasing sequence of numbers for each row.

3. Generate decreasing numbers

row += list(range(2 * i - 2, i - 1, -1))

This adds the decreasing sequence, creating a symmetrical number arrangement.

4. Manage the spacing

" " * (n - i)

This adds leading spaces before each row to create the diamond shape.

5. Print the upper half

for i in range(1, n + 1):

The loop gradually increases the number of elements until it reaches the widest row.

6. Print the lower half

for i in range(n - 1, 0, -1):

The reverse loop recreates the same structure in decreasing order, completing the diamond.

๐Ÿš€ Challenge Yourself

  • Increase the maximum number from 9 to 11.

  • Replace numbers with alphabets.

  • Create an inverted number diamond.

  • Try generating the pattern using nested loops.

  • Experiment with different number sequences.

๐Ÿ’ก What Will You Learn?

By completing this challenge, you will practice:

  • Python for loops

  • range() function

  • List creation and concatenation

  • Number sequences

  • map() function

  • String formatting

  • Symmetrical pattern logic

๐ŸŽฏ Final Thoughts

Number patterns are an excellent way to improve your programming logic. They teach you how to combine mathematical sequences, loops, and spacing to create beautiful designs.

Keep practicing and challenge yourself with more complex Python patterns!

56 Days. 56 Patterns. Stronger Python Logic! ๐Ÿ๐Ÿ”ฅ

Learn • Practice • Grow with CLCODING


0 Comments:

Post a Comment

Popular Posts

Categories

100 Python Programs for Beginner (119) AI (365) Android (25) AngularJS (1) API (2) Assembly Language (2) aws (31) Azure (12) BI (10) book (1) Books (359) Bootcamp (21) C (78) C# (12) C++ (83) cloud (1) Course (98) Coursera (309) Cybersecurity (38) data (11) Data Analysis (48) Data Analytics (32) data management (17) Data Science (449) Data Strucures (22) Deep Learning (229) Django (17) Downloads (3) edx (21) Engineering (15) Euron (30) Events (9) Excel (24) Finance (13) flask (4) flutter (1) FPL (17) Gadgets (2) Generative AI (80) Git (14) Google (55) Hadoop (3) HTML Quiz (1) HTML&CSS (48) IBM (43) IoT (3) IS (25) Java (99) Leet Code (4) Machine Learning (421) Meta (24) MICHIGAN (5) microsoft (14) Nvidia (8) Pandas (16) PHP (20) Projects (36) Python (1418) Python Bug (1) Python Coding Challenge (1322) Python Library (29) Python Mathematics (25) Python Mistakes (51) Python Pattern Challenge (52) Python Quiz (705) Python Tips (115) Python Turtle (3) Questions (3) R (72) RAG (3) React (7) Scripting (3) security (5) Selenium Webdriver (4) Software (21) SQL (57) Udemy (25) UX Research (1) web application (11) Web development (9) web scraping (3)

Followers

Python Coding for Kids ( Free Demo for Everyone)