A curated daily collection of pattern printing challenges to master loops, logic, and problem-solving in Python.
Browse Patterns • Repository Structure • How to Run • Logic Cheat Sheet
Pattern printing is one of the best ways to build a rock-solid foundation in:
- Nested loop mechanics (outer loops for rows, inner loops for columns/spaces)
- Mathematical and index manipulation
- Spatial reasoning and algorithmic thinking
This repository tracks my journey of uploading at least one new pattern problem every day, complete with multiple approaches (nested loops vs. string multiplication) and visual output examples.
Patterns/
│
├── Star-Pattern/ # Star & symbol patterns
│ ├── LeftSideTriangle.py # Day 01: Left-sided upright triangle
│ ├── LeftReverseTriangle.py # Day 02: Inverted left-sided triangle
│ ├── LeftTriangleOutline.py # Day 03: Hollow left-sided triangle outline
│ ├── LeftTriangleInvertedOutline.py # Day 04: Hollow inverted left-sided triangle outline
│ ├── RightSideTriangle.py # Day 05: Right-sided upright triangle
│ ├── RightInvertedTriangle.py # Day 06: Inverted right-sided triangle
│ ├── RightTriangleOutline.py # Day 07: Hollow right-sided triangle outline
│ ├── RightTriangleInvertedOutline.py # Day 08: Hollow inverted right-sided triangle outline
│ ├── CenterTriangle.py # Day 09: Equilateral centered triangle
│ ├── CenterInvertedTriangle.py # Day 10: Inverted centered triangle
│ ├── CenterTriangleOutline.py # Day 11: Hollow centered triangle outline
│ ├── CenterInvertedTriangleOutline.py # Day 12: Hollow inverted centered triangle outline
│ └── DiamondPattern.py # Day 13: Solid diamond star pattern
│
├── Number-Pattern/ # (Upcoming) Number triangles, Pascal, Floyd's
├── Alphabet-Pattern/ # (Upcoming) Character pyramids, letter matrices
└── Advanced-Pattern/ # (Upcoming) Hollow shapes, butterfly, spirals
| Day | Pattern Name | Category | Code Link | Visual Preview |
|---|---|---|---|---|
| 01 | Left-Sided Triangle | Star | LeftSideTriangle.py |
****** |
| 02 | Left Reverse Triangle | Star | LeftReverseTriangle.py |
****** |
| 03 | Left Triangle Outline | Star | LeftTriangleOutline.py |
**** ** ****** |
| 04 | Inverted Left Triangle Outline | Star | LeftTriangleInvertedOutline.py |
****** ** **** |
| 05 | Right-Sided Triangle | Star | RightSideTriangle.py |
* ***** |
| 06 | Right Inverted Triangle | Star | RightInvertedTriangle.py |
*** ** * |
| 07 | Right Triangle Outline | Star | RightTriangleOutline.py |
* ** * * * ****** |
| 08 | Inverted Right Triangle Outline | Star | RightTriangleInvertedOutline.py |
***** * * * * ** * |
| 09 | Center Triangle | Star | CenterTriangle.py |
* * ** * * |
| 10 | Center Inverted Triangle | Star | CenterInvertedTriangle.py |
* * * * * * |
| 11 | Center Triangle Outline | Star | CenterTriangleOutline.py |
* * * * * * ********** |
| 12 | Center Inverted Triangle Outline | Star | CenterInvertedTriangleOutline.py |
********* * * * * * * * |
| 13 | Diamond Pattern | Star | DiamondPattern.py |
* * ** * * * * * |
git clone https://github.com/GOKUL05102003/Pattern-Programming.git
cd Pattern-ProgrammingRun any pattern script directly using Python:
# General Syntax:
python <folder-name>/<file-name>.py
# Examples:
python Star-Pattern/LeftSideTriangle.py
python Star-Pattern/LeftReverseTriangle.py
python Star-Pattern/LeftTriangleOutline.py
python Star-Pattern/LeftTriangleInvertedOutline.py
python Star-Pattern/RightSideTriangle.py
python Star-Pattern/RightInvertedTriangle.py
python Star-Pattern/RightTriangleOutline.py
python Star-Pattern/RightTriangleInvertedOutline.py
python Star-Pattern/CenterTriangle.py
python Star-Pattern/CenterInvertedTriangle.py
python Star-Pattern/CenterTriangleOutline.py
python Star-Pattern/CenterInvertedTriangleOutline.py
python Star-Pattern/DiamondPattern.pyWhen prompted, enter the number of rows (e.g., 5):
Enter the no. of Rows: 5
When solving any pattern problem, follow this 4-step framework:
-
Rows (Outer Loop): Count the total rows (
$n$ ). Loop from1ton(orndown to1for reverse patterns). -
Spaces (Inner Loop 1): Determine if spaces depend on the row index (e.g.,
$n - i$ ). -
Symbols / Values (Inner Loop 2): Identify how characters change per line (e.g., boundary conditions
j == 1 or j == i or i == nfor outlines). - New Line: Print a line break after each row finishes printing.
- If you have any feedback, ideas, or suggestions, feel free to open an Issue!
- If you find this project helpful for your learning journey, please leave a Star ⭐ to support the repository.