Star Patterns - Logic Practice | Python Loop Visualizer

Star Patterns

BLUF: Python Star Patterns are a fundamental way to master nested loop logic. By using this visualizer, you can see exactly how row and column counters interact to build complex triangles, diamonds, and pyramids.
Nested Loop Visualization

Patterns are built using two loops: the outer loop controls the number of rows, while the inner loop controls the characters (stars or spaces) in each line.

Click "Visualize" to see how each pattern builds step-by-step

Right Triangle
*
**
***
****
*****
Inverted Triangle
*****
****
***
**
*
Pyramid
    *
   ***
  *****
 *******
*********
Diamond
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *
Hollow Square
*****
*   *
*   *
*   *
*****
Butterfly
*        *
**      **
***    ***
****  ****
**********
**********
****  ****
***    ***
**      **
*        *
Number Triangle
1
12
123
1234
12345
Floyd's Triangle
1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15
Sandglass
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********
Hollow Pyramid
    *
   * *
  *   *
 *     *
*********
Right Arrow
*
**
***
****
*****
****
***
**
*
Star Grid Pattern
* * * * * 
* * * * * 
* * * * * 
* * * * *
Coordinate Pair Pattern
1 1 2 1 3 1 
1 2 2 2 3 2 
1 3 2 3 3 3 
1 4 2 4 3 4 
1 5 2 5 3 5
Reverse Coordinate Pair Pattern
1 1 1 2 1 3 
2 1 2 2 2 3 
3 1 3 2 3 3 
4 1 4 2 4 3 
5 1 5 2 5 3
Column-wise Sequential Pattern
 1  6 11 16 21 
 2  7 12 17 22 
 3  8 13 18 23 
 4  9 14 19 24 
 5 10 15 20 25
Alternating Row Pattern
 1 10 11 20 21 
 2  9 12 19 22 
 3  8 13 18 23 
 4  7 14 17 24 
 5  6 15 16 25
Descending Sequential Pattern
 5 10 15 20 25 
 4  9 14 19 24 
 3  8 13 18 23 
 2  7 12 17 22 
 1  6 11 16 21
Alternating Sequential Pattern
 5  6 15 16 25 
 4  7 14 17 24 
 3  8 13 18 23 
 2  9 12 19 22 
 1 10 11 20 21
Sum Pattern
 1 2 3 4 5 
 2 3 4 5 6 
 3 4 5 6 7 
 4 5 6 7 8 
 5 6 7 8 9
Odd Number Sum Pattern
 1  3  5  7  9 
 3  5  7  9 11 
 5  7  9 11 13 
 7  9 11 13 15 
 9 11 13 15 17
Binary Checkerboard Pattern
 0 1 0 1 0 
 1 0 1 0 1 
 0 1 0 1 0 
 1 0 1 0 1 
 0 1 0 1 0
Modulo Sum Pattern
 1  0  1  0  1 
 0  1  0  1  0 
 1  0  1  0  1 
 0  1  0  1  0 
 1  0  1  0  1
Row Number Grid Pattern
1 1 1 1 1 
2 2 2 2 2 
3 3 3 3 3 
4 4 4 4 4
Multiplication Modulo Pattern
 1 0 1 0 1 
 0 0 0 0 0 
 1 0 1 0 1 
 0 0 0 0 0 
 1 0 1 0 1
Zero-Based Multiplication Pattern
 0 1 0 1 0 
 0 0 0 0 0 
 0 1 0 1 0 
 0 0 0 0 0 
 0 1 0 1 0
Row Parity Pattern
 0 0 0 0 0 
 1 1 1 1 1 
 0 0 0 0 0 
 1 1 1 1 1 
 0 0 0 0 0
Column Parity Pattern
 1 1 1 1 1 
 0 0 0 0 0 
 1 1 1 1 1 
 0 0 0 0 0 
 1 1 1 1 1
Zero-Based Column Pattern
 0 1 0 1 0 
 0 1 0 1 0 
 0 1 0 1 0 
 0 1 0 1 0 
 0 1 0 1 0
Column Modulo Pattern
 1 0 1 0 1 
 1 0 1 0 1 
 1 0 1 0 1 
 1 0 1 0 1 
 1 0 1 0 1
Alphabet Row Pattern
 A A A A A 
 B B B B B 
 C C C C C 
 D D D D D 
 E E E E E
Sequential Alphabet Pattern
 A B C D E 
 A B C D E 
 A B C D E 
 A B C D E 
 A B C D E
Descending Alphabet Row Pattern
 E E E E E 
 D D D D D 
 C C C C C 
 B B B B B 
 A A A A A
Reverse Alphabet Row Pattern
 E D C B A 
 E D C B A 
 E D C B A 
 E D C B A 
 E D C B A
Column Number Grid Pattern
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5
Sequential Alphabet Grid Pattern
 A B C D E 
 F G H I J 
 K L M N O 
 P Q R S T 
 U V W X Y
Alphabet Addition Pattern
 A B C D E 
 B C D E F 
 C D E F G 
 D E F G H 
 E F G H I
Column-wise Alphabet Pattern
 A F K P U 
 B G L Q V 
 C H M R W 
 D I N S X 
 E J O T Y
Descending Alphabet Pattern
 E J O T Y 
 D I N S X 
 C H M R W 
 B G L Q V 
 A F K P U
Right Triangle Star Pattern
 * 
 * * 
 * * * 
 * * * * 
 * * * * *
Row Repetition Number Pattern
 1 
 2 2 
 3 3 3 
 4 4 4 4 
 5 5 5 5 5
Sequential Number Triangle Pattern
 1 
 1 2 
 1 2 3 
 1 2 3 4 
 1 2 3 4 5
Descending Row Repetition Pattern
 5 
 4 4 
 3 3 3 
 2 2 2 2 
 1 1 1 1 1
Descending Sequence Triangle Pattern
 5 
 5 4 
 5 4 3 
 5 4 3 2 
 5 4 3 2 1
Descending Start Sequence Pattern
 5 
 4 5 
 3 4 5 
 2 3 4 5 
 1 2 3 4 5
Descending Row Number Grid Pattern
5 5 5 5 5 
4 4 4 4 4 
3 3 3 3 3 
2 2 2 2 2 
1 1 1 1 1
Even Number Triangle Pattern
 2 
 2 4 
 2 4 6 
 2 4 6 8 
 2 4 6 8 10
Sequential Number Triangle Pattern
 1 
 2 3 
 4 5 6 
 7 8 9 10
Sum Offset Triangle Pattern
 1 
 2 3 
 3 4 5 
 4 5 6 7 
 5 6 7 8 9
Odd Number Progression Pattern
 1 
 3 5 
 5 7 9 
 7 9 11 13 
 9 11 13 15 17
Reverse Sequential Triangle Pattern
 1 
 3 2 
 6 5 4 
 10 9 8 7
Ascending Odd Number Triangle Pattern
  1 
  3  5 
  7  9 11 
 13 15 17 19 
 21 23 25 27 29
Ascending Even Number Triangle Pattern
  2 
  4  6 
  8 10 12 
 14 16 18 20 
 22 24 26 28 30
Complex Descending Pattern
  1 
  6  2 
 10  7  3 
 13 11  8  4 
 15 14 12  9  5
Diagonal Cascade Pattern
  1 
  9  2 
 10  8  3 
 14 11  7  4 
 15 13 12  6  5
Descending Column Number Grid Pattern
5 4 3 2 1 
5 4 3 2 1 
5 4 3 2 1 
5 4 3 2 1 
5 4 3 2 1
Alternating Complex Pattern
5 
6  4 
12 7  3 
13 11 8  2 
15 14 10  9  1
Sequential Number Grid Pattern
 1  2  3  4  5 
 6  7  8  9 10 
11 12 13 14 15 
16 17 18 19 20 
21 22 23 24 25
Odd Number Grid Pattern
 1  3  5  7  9 
11 13 15 17 19 
21 23 25 27 29 
31 33 35 37 39 
41 43 45 47 49
Even Number Grid Pattern
 2  4  6  8 10 
12 14 16 18 20 
22 24 26 28 30 
32 34 36 38 40 
42 44 46 48 50
Multiplication Table Pattern
 1  2  3  4  5 
 2  4  6  8 10 
 3  6  9 12 15 
 4  8 12 16 20 
 5 10 15 20 25

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience