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
│
├── 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 |
****** |
git clone https://github.com/your-username/Python-Patterns.git
cd Python-PatternsRun any pattern script directly using Python:
# General Syntax:
python <folder-name>/<file-name>.py
# Examples:
python Star-Pattern/LeftSideTriangle.py
python Star-Pattern/LeftReverseTriangle.pyWhen prompted, enter the number of rows (e.g., 5):
enter 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.,
$2i - 1$ ,$i$ , etc.). - 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.