🐍 Python for Everyone

← Back to interview questions

Chapter 5 Project 20 min build

Number Pattern Generator

Pattern printing is a classic exercise for building real comfort with nested loops — and a genuinely common interview warm-up question.

Example run

Output
--- Pattern 1: Increasing triangle ---
1
12
123
1234
12345
--- Pattern 2: Star pyramid ---
*
**
***
****
*****
--- Pattern 3: Decreasing triangle ---
54321
5432
543
54
5
How to run Download starter.py below and run python3 starter.py.

Ideas to make it your own

Why this project matters

Nested loops are exactly how you'd process a grid, a matrix, or any two-dimensional data. The underlying skill — an outer loop controlling rows, an inner loop controlling columns — is used constantly in real software.

← Interview Questions All Chapters →