Nearby lessons

112 of 112

Python Pattern Programs

Introduction

Pattern programs are one of the best ways to understand loops in Python.

In pattern programs, we normally use:

  • for loops
  • Nested for loops
  • range()
  • print()
  • end parameter
  • Row and column logic

In this part, we will learn the first three patterns:

Pattern-1 → Square Star Pattern

Pattern-2 → Same Row Number Pattern

Pattern-3 → Increasing Column Number Pattern

Understanding these basic patterns is important because many advanced patterns are created using the same row and column concepts.

Pattern-1 — Square Star Pattern

In Pattern-1, we print a square made of * symbols.

If the user enters:

10

then the program prints:

  • 10 rows
  • 10 stars in every row
Rows    = n
Columns = n

Therefore, for n = 10, we get a 10 × 10 star pattern.

Pattern-1 — Output

* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *

Pattern-1 — Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-1 — Program Explanation

Let's understand the program line by line.

Line 1

n=int(input("Enter the number of rows: "))

input() accepts the number of rows from the user.

By default, input() returns a string. Therefore, int() converts that value into an integer.

For example:

Enter the number of rows: 10

n = 10

Line 2

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

This loop controls the number of rows.

If:

n = 10

then:

range(1,n+1)

becomes

range(1,11)

The values of i are:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Therefore, the loop executes 10 times.

Line 3

print("* "*n)

The string:

"* "

contains one star followed by one space.

Multiplying this string by n repeats it n times.

For example:

"* " * 5

produces:

* * * * *

For n = 10:

"* " * 10

produces 10 stars.

Because the print() statement executes once for every iteration of the outer loop, the same row is printed 10 times.

Pattern-1 — Understanding String Multiplication

Python allows us to multiply a string by an integer.

Example:

print("* " * 3)

Output:

* * *

Similarly:

print("* " * 5)

Output:

* * * * *

Therefore:

"* " * n

means:

Print "* " n times

Pattern-1 — Row Logic

The loop controls how many rows are printed.

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

For n = 10:

Iteration i Output
1110 Stars
2210 Stars
3310 Stars
4410 Stars
5510 Stars
6610 Stars
7710 Stars
8810 Stars
9910 Stars
101010 Stars

Notice that i is not used inside print().

Its purpose is only to repeat the statement n times.

Pattern-1 — Dry Run with n = 3

Suppose:

n = 3

The loop becomes:

for i in range(1,4):

Execution:

i Expression Printed Row
1 "* " * 3 * * *
2 "* " * 3 * * *
3 "* " * 3 * * *

Final output:

* * *
* * *
* * *

Pattern-1 — Execution Flow

START
  │
  ▼
Read n
  │
  ▼
i = 1
  │
  ▼
Is i <= n?
  │
  ├── No ─────────────► END
  │
 Yes
  │
  ▼
Print "* " n times
  │
  ▼
Move to next i
  │
  └──────────────► Check i <= n again

Pattern-1 — Important Points

  • n represents the number of rows.
  • The for loop executes n times.
  • "* " * n creates n stars.
  • Every row contains the same number of stars.
  • The result is a square star pattern.
  • This pattern does not require a nested loop because Python string multiplication is used.

Pattern-2 — Same Row Number Pattern

Pattern-2 prints numbers in a square format.

The important rule is:

Row 1 → print 1
Row 2 → print 2
Row 3 → print 3
...
Row n → print n

Every row contains n values.

Therefore:

Row Number = Printed Number

This pattern introduces the concept of nested loops.

Pattern-2 — Output

1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6 6 6
7 7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9 9
10 10 10 10 10 10 10 10 10 10

Pattern-2 — Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-2 — Nested Loop Concept

This program contains two loops:

Outer Loop → Controls Rows

Inner Loop → Controls Columns

The structure is:

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

    for j in range(1,n+1):   ← Columns

        print(i,end=" ")

Therefore:

i → Row Number
j → Column Number

Pattern-2 — Outer Loop Explanation

The outer loop is:

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

It controls the rows.

For n = 10, i takes the values:

1
2
3
4
5
6
7
8
9
10

Each value represents one row.

i = 1 → First row
i = 2 → Second row
i = 3 → Third row
...
i = 10 → Tenth row

Pattern-2 — Inner Loop Explanation

The inner loop is:

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

It controls the number of columns.

For every row, the inner loop executes n times.

If n = 10:

j = 1,2,3,4,5,6,7,8,9,10

Therefore, each row contains 10 values.

Pattern-2 — Why print(i)?

The important statement is:

print(i,end=" ")

We print i, not j.

Since i represents the current row number, the same number is printed throughout that row.

For example:

i = 1

The inner loop executes 10 times:

print(1)
print(1)
print(1)
...

Therefore:

1 1 1 1 1 1 1 1 1 1

When:

i = 2

we get:

2 2 2 2 2 2 2 2 2 2

Pattern-2 — Understanding end=' '

Normally:

print(i)

moves the cursor to the next line after printing.

But this pattern needs multiple values on the same line.

Therefore, we use:

print(i,end=" ")

The end=" " tells Python:

After printing the value,
do not move to the next line.
Add one space instead.

This allows all column values to remain on the same row.

Pattern-2 — Why print() is Required

After the inner loop finishes, we use:

print()

This moves the cursor to the next line.

The flow is:

Print all columns of Row 1
          │
          ▼
       print()
          │
          ▼
Move to Row 2

Without this final print(), all numbers would continue on the same line.

Pattern-2 — Dry Run with n = 3

Suppose:

n = 3

The program becomes logically:

i = 1
    j = 1 → print 1
    j = 2 → print 1
    j = 3 → print 1

i = 2
    j = 1 → print 2
    j = 2 → print 2
    j = 3 → print 2

i = 3
    j = 1 → print 3
    j = 2 → print 3
    j = 3 → print 3

Output:

1 1 1
2 2 2
3 3 3

Pattern-2 — Iteration Table

i j Values Printed Value Row Output
1 1, 2, 3 i = 1 1 1 1
2 1, 2, 3 i = 2 2 2 2
3 1, 2, 3 i = 3 3 3 3

Pattern-2 — Execution Flow

START
  │
  ▼
Read n
  │
  ▼
Start Outer Loop
i = 1 to n
  │
  ▼
Start Inner Loop
j = 1 to n
  │
  ▼
Print i
  │
  ▼
More columns?
  │
  ├── Yes ──► Next j ──► Print i
  │
  No
  │
  ▼
print()
  │
  ▼
Move to Next Row
  │
  ▼
More rows?
  │
  ├── Yes ──► Next i
  │
  No
  │
  ▼
 END

Pattern-2 — Important Points

  • The outer loop controls rows.
  • The inner loop controls columns.
  • Both loops execute n times.
  • i represents the row number.
  • j represents the column iteration.
  • The program prints i, so the same number appears throughout each row.
  • end=" " keeps numbers on the same line.
  • print() moves execution to the next output line after one row is completed.

Pattern-3 — Increasing Column Number Pattern

Pattern-3 also creates a square number pattern.

However, instead of repeating the row number, every row prints:

1 2 3 4 ... n

For n = 10, every row contains:

1 2 3 4 5 6 7 8 9 10

The important rule is:

Printed Number = Column Number

Pattern-3 — Output

1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10

Pattern-3 — Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-3 — Program Explanation

This program is very similar to Pattern-2.

The main difference is:

Pattern-2:

print(i,end=" ")


Pattern-3:

print(j,end=" ")

This small change produces a completely different pattern.

In Pattern-3:

i → controls rows

j → controls columns and is also printed

Pattern-3 — Outer Loop

The outer loop is:

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

Its job is to control the number of rows.

For n = 10:

i = 1 to 10

Therefore, 10 rows are generated.

Notice that i is not printed in this pattern.

Pattern-3 — Inner Loop

The inner loop is:

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

For every row, j takes values from 1 to n.

For n = 10:

j = 1
j = 2
j = 3
j = 4
j = 5
j = 6
j = 7
j = 8
j = 9
j = 10

Because the program prints j:

print(j,end=" ")

each row becomes:

1 2 3 4 5 6 7 8 9 10

Pattern-3 — Why Every Row is the Same

The inner loop always starts again from:

j = 1

whenever a new outer-loop iteration starts.

Consider:

i = 1

j → 1 2 3 4 5

After the first row finishes, the outer loop moves to:

i = 2

The inner loop starts again:

j → 1 2 3 4 5

Therefore, every row contains the same increasing number sequence.

Pattern-3 — Dry Run with n = 3

Suppose:

n = 3

Outer Loop — i = 1

j = 1 → print 1
j = 2 → print 2
j = 3 → print 3

First row:

1 2 3

Outer Loop — i = 2

The inner loop starts again:

j = 1 → print 1
j = 2 → print 2
j = 3 → print 3

Second row:

1 2 3

Outer Loop — i = 3

j = 1 → print 1
j = 2 → print 2
j = 3 → print 3

Third row:

1 2 3

Final output:

1 2 3
1 2 3
1 2 3

Pattern-3 — Iteration Table

Row (i) j Values Values Printed
1 1, 2, 3 1 2 3
2 1, 2, 3 1 2 3
3 1, 2, 3 1 2 3

Pattern-3 — Execution Flow

START
  │
  ▼
Read n
  │
  ▼
Start Outer Loop
i = 1 to n
  │
  ▼
Start Inner Loop
j = 1 to n
  │
  ▼
Print j
  │
  ▼
Next j
  │
  ▼
Is inner loop complete?
  │
  ├── No ─────► Print next j
  │
 Yes
  │
  ▼
print()
  │
  ▼
Move to next row
  │
  ▼
Is outer loop complete?
  │
  ├── No ─────► Start j from 1 again
  │
 Yes
  │
  ▼
 END

Pattern-2 vs Pattern-3

Pattern-2 and Pattern-3 use almost the same nested-loop structure.

The important difference is the variable being printed.

Feature Pattern-2 Pattern-3
Outer Loop i i
Inner Loop j j
Printed Variable i j
Row 1 1 1 1 1 2 3
Row 2 2 2 2 1 2 3
Row 3 3 3 3 1 2 3

Main Rule

print(i) → Pattern depends on ROW

print(j) → Pattern depends on COLUMN

This is one of the most important concepts to understand before moving to more advanced pattern programs.

Pattern-3 — Important Points

  • The outer loop controls rows.
  • The inner loop controls columns.
  • j starts from 1 for every new row.
  • The program prints j, so values increase from left to right.
  • Every row contains the same number sequence.
  • end=" " keeps the values on the same row.
  • The empty print() starts the next row.

Part 1A — Complete Comparison

Pattern Type Main Logic
Pattern-1 Square Star Pattern "* " * n
Pattern-2 Same Row Number print(i,end=" ")
Pattern-3 Increasing Column Numbers print(j,end=" ")

Part 1A — Core Pattern Programming Concept

The first three patterns introduce an important idea:

                  PATTERN PROGRAM
                        │
              ┌─────────┴─────────┐
              │                   │
              ▼                   ▼
            Rows                Columns
              │                   │
              ▼                   ▼
         Outer Loop           Inner Loop
              │                   │
              ▼                   ▼
              i                   j

In most pattern programs:

i = Row

j = Column

Then we decide what should be printed by creating an expression using:

i
j
n

For example:

print(i) → Row-based pattern

print(j) → Column-based pattern

Understanding this concept will make the upcoming number, alphabet, triangle, pyramid and reverse patterns much easier.

Part 1A — Summary

In Part 1A, we completed Pattern-1, Pattern-2 and Pattern-3.

Pattern-1

* * *
* * *
* * *

Uses string multiplication:

"* " * n

Pattern-2

1 1 1
2 2 2
3 3 3

Prints the outer-loop variable:

print(i,end=" ")

Pattern-3

1 2 3
1 2 3
1 2 3

Prints the inner-loop variable:

print(j,end=" ")

Golden Rule

Outer Loop → Rows
Inner Loop → Columns

i → Row
j → Column

Introduction

In Part 1B, we continue with square patterns.

We will learn:

Pattern-4 → Reverse Number Square
Pattern-5 → Same Row Alphabet Square
Pattern-6 → Increasing Alphabet Square

The main concepts are:

  • Reverse range()
  • Nested loops
  • chr()
  • ASCII values
  • Row-based alphabet patterns
  • Column-based alphabet patterns

Pattern-4 — Reverse Number Square Pattern

This pattern prints numbers from n to 1 in every row.

For n = 10:

10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1

The important logic is:

Rows    → 1 to n
Columns → n to 1

Pattern-4 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-4 — Program Explanation

Outer Loop

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

The outer loop controls the rows.

Inner Loop

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

This is a reverse loop.

For n = 10:

j = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1

The third argument:

-1

means decrease the value by one after every iteration.

Printing

print(j,end=" ")

Since j is printed, numbers appear in reverse order.

Pattern-4 — Understanding range(n,0,-1)

The syntax of range() is:

range(start, stop, step)

Here:

range(n, 0, -1)

start = n
stop  = 0
step  = -1

The stop value is excluded.

Therefore, for n = 5:

range(5,0,-1)

5, 4, 3, 2, 1

Pattern-4 — Dry Run with n = 3

i = 1
j = 3 → print 3
j = 2 → print 2
j = 1 → print 1

i = 2
j = 3 → print 3
j = 2 → print 2
j = 1 → print 1

i = 3
j = 3 → print 3
j = 2 → print 2
j = 1 → print 1

Output:

3 2 1
3 2 1
3 2 1

Pattern-4 — Execution Flow

Read n
  │
  ▼
Outer Loop: i = 1 to n
  │
  ▼
Inner Loop: j = n to 1
  │
  ▼
Print j
  │
  ▼
j = j - 1
  │
  ▼
Inner Loop Complete?
  │
  ├── No → Continue
  │
 Yes
  ▼
print()
  │
  ▼
Next Row

Pattern-5 — Same Row Alphabet Square

Pattern-5 prints one alphabet repeatedly in every row.

A A A A A A A A A A
B B B B B B B B B B
C C C C C C C C C C
D D D D D D D D D D
E E E E E E E E E E
F F F F F F F F F F
G G G G G G G G G G
H H H H H H H H H H
I I I I I I I I I I
J J J J J J J J J J

The rule is:

Row 1 → A
Row 2 → B
Row 3 → C
...
Row 10 → J

Pattern-5 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-5 — Understanding chr()

Python's chr() converts an integer Unicode code point into its corresponding character.

For uppercase English letters:

ExpressionValueCharacter
chr(65)65A
chr(66)66B
chr(67)67C
chr(68)68D

The program uses:

chr(64+i)

Therefore:

i = 1 → chr(65) → A
i = 2 → chr(66) → B
i = 3 → chr(67) → C

Pattern-5 — Dry Run with n = 3

i = 1
chr(64+1) = chr(65) = A
→ A A A

i = 2
chr(64+2) = chr(66) = B
→ B B B

i = 3
chr(64+3) = chr(67) = C
→ C C C

Output:

A A A
B B B
C C C

Pattern-5 — Main Formula

Character = chr(64 + i)

Since the formula uses i, the alphabet depends on the row number.

i → Row
     │
     ▼
64 + i
     │
     ▼
chr()
     │
     ▼
Alphabet

Pattern-6 — Increasing Alphabet Square

Pattern-6 prints increasing alphabets from left to right.

Every row follows:

A B C D E F G H I J

The same sequence is repeated for every row.

Pattern-6 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-6 — Program Explanation

The main expression is:

chr(64+j)

Here the alphabet depends on j.

j = 1 → A
j = 2 → B
j = 3 → C
...
j = 10 → J

Since the inner loop restarts for every row, each row again starts from A.

Pattern-6 — Dry Run with n = 3

i = 1:
j = 1 → A
j = 2 → B
j = 3 → C

i = 2:
j = 1 → A
j = 2 → B
j = 3 → C

i = 3:
j = 1 → A
j = 2 → B
j = 3 → C

Output:

A B C
A B C
A B C

Pattern-5 vs Pattern-6

PatternExpressionDepends On
Pattern-5chr(64+i)Row
Pattern-6chr(64+j)Column
chr(64+i) → Row-based alphabet

chr(64+j) → Column-based alphabet

Part 1B — Summary

PatternMain Logic
4range(n,0,-1)
5chr(64+i)
6chr(64+j)

Part 1B introduces two especially important concepts: reverse ranges and converting numbers into alphabet characters using chr().

Introduction

Part 3 introduces right-aligned and right-shifted pattern programs.

We will learn:

Pattern-21 → Decreasing Repeated Reverse Alphabets
Pattern-22 → Decreasing Reverse Alphabet Sequence

Pattern-23 → Right-Aligned Star Triangle without Spaces
Pattern-24 → Right-Aligned Star Triangle with Spaces
Pattern-25 → Right-Aligned Repeated Number Triangle
Pattern-26 → Right-Aligned Increasing Number Triangle
Pattern-27 → Right-Aligned Repeated Alphabet Triangle
Pattern-28 → Right-Aligned Increasing Alphabet Triangle

Pattern-29 → Right-Shifted Decreasing Star Triangle
Pattern-30 → Right-Shifted Decreasing Repeated Number Triangle

The most important new concept is leading spaces.

Increasing right-aligned pattern:

Spaces = n - i
Values = i

As the row number increases:

Spaces ↓
Values ↑

Pattern-21 — Decreasing Repeated Reverse Alphabet Triangle

Pattern-21 prints alphabets from J to A.

The number of characters also decreases in every row.

J J J J J J J J J J
I I I I I I I I I
H H H H H H H H
G G G G G G G
F F F F F F
E E E E E
D D D D
C C C
B B
A

For every row:

Character Count = n + 1 - i
Character       = chr(64 + n + 1 - i)

Pattern-21 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-21 — Program Explanation

Outer Loop

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

The outer loop controls the rows.

Inner Loop

for j in range(1,n+2-i):

The actual number of iterations is:

n + 1 - i

Therefore, the number of characters decreases row by row.

Character Formula

chr(64+n+1-i)

For n = 10:

i = 1 → chr(64+10+1-1)
      → chr(74)
      → J

i = 2 → chr(73)
      → I

i = 3 → chr(72)
      → H

...

i = 10 → chr(65)
       → A

Pattern-21 — Dry Run with n = 5

i Character Times Printed Output
1E5E E E E E
2D4D D D D
3C3C C C
4B2B B
5A1A

Pattern-22 — Decreasing Reverse Alphabet Sequence

Pattern-22 prints reverse alphabets in each row.

J I H G F E D C B A
J I H G F E D C B
J I H G F E D C
J I H G F E D
J I H G F E
J I H G F
J I H G
J I H
J I
J

The first alphabet always starts from J when n = 10.

The number of alphabets decreases after every row.

Pattern-22 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-22 — Formula Explanation

The character formula is:

chr(65+n-j)

For n = 10:

j = 1 → chr(65+10-1)
      → chr(74)
      → J

j = 2 → chr(73)
      → I

j = 3 → chr(72)
      → H

Because the expression depends on j, the character changes inside the row.

Pattern-21 vs Pattern-22

Pattern Formula Depends On Result
21 chr(64+n+1-i) Row Same alphabet repeated
22 chr(65+n-j) Column Reverse alphabet sequence
Pattern-21:

E E E E E
D D D D
C C C
B B
A


Pattern-22:

E D C B A
E D C B
E D C
E D
E

Understanding Right-Aligned Patterns

Starting from Pattern-23, spaces are printed before the actual pattern.

The basic formula is:

" " * (n-i)

For n = 5:

Row i Leading Spaces Pattern Size
141
232
323
414
505

So:

Leading Spaces = n - i
Pattern Size   = i

Pattern-23 — Right-Aligned Star Triangle without Spaces

Pattern-23 creates a right-aligned increasing star triangle.

         *
        **
       ***
      ****
     *****
    ******
   *******
  ********
 *********
**********

The stars do not contain spaces between them.

Pattern-23 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-23 — Program Explanation

The statement:

" " * (n-i)

generates the leading spaces.

The statement:

"*" * i

generates the stars.

Therefore:

Spaces = n - i
Stars  = i

For n = 5:

i = 1 → 4 spaces + 1 star
i = 2 → 3 spaces + 2 stars
i = 3 → 2 spaces + 3 stars
i = 4 → 1 space  + 4 stars
i = 5 → 0 spaces + 5 stars

Pattern-23 — Dry Run with n = 5

i = 1
" " * 4 + "*" * 1
    *

i = 2
" " * 3 + "*" * 2
   **

i = 3
" " * 2 + "*" * 3
  ***

i = 4
" " * 1 + "*" * 4
 ****

i = 5
" " * 0 + "*" * 5
*****

Pattern-24 — Right-Aligned Star Triangle with Spaces

Pattern-24 is similar to Pattern-23, but every star is followed by a space.

         *
        * *
       * * *
      * * * *
     * * * * *
    * * * * * *
   * * * * * * *
  * * * * * * * *
 * * * * * * * * *
* * * * * * * * * *

Pattern-24 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-24 — Program Explanation

First, spaces are printed:

print(" "*(n-i),end="")

Then the inner loop prints stars:

for j in range(1,i+1):
    print("*",end=" ")

The number of stars equals i.

Spaces = n - i
Stars  = i

Pattern-23 vs Pattern-24

Pattern Star Logic Appearance
23 "*"*i Stars joined together
24 print("*",end=" ") Space after every star
Pattern-23 → *****

Pattern-24 → * * * * *

Pattern-25 — Right-Aligned Repeated Number Triangle

         1
        2 2
       3 3 3
      4 4 4 4
     5 5 5 5 5
    6 6 6 6 6 6
   7 7 7 7 7 7 7
  8 8 8 8 8 8 8 8
 9 9 9 9 9 9 9 9 9
10 10 10 10 10 10 10 10 10 10

The row number is repeated according to the current row.

Row 1  → 1 once
Row 2  → 2 twice
Row 3  → 3 three times
...

Pattern-25 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-25 — Program Explanation

Leading spaces:

" " * (n-i)

The number string is:

str(i) + " "

It is repeated i times:

(str(i)+" ") * i

For example:

i = 3

str(i) + " "
→ "3 "

"3 " * 3
→ "3 3 3 "

The document contains an additional print() after this statement, so the source program has been preserved exactly.

Pattern-26 — Right-Aligned Increasing Number Triangle

         1
        1 2
       1 2 3
      1 2 3 4
     1 2 3 4 5
    1 2 3 4 5 6
   1 2 3 4 5 6 7
  1 2 3 4 5 6 7 8
 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10

Pattern-26 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-26 — Program Explanation

The leading-space formula remains:

n - i

The inner loop is:

range(1,i+1)

and prints:

j

Therefore:

i = 1 → 1
i = 2 → 1 2
i = 3 → 1 2 3
i = 4 → 1 2 3 4

The pattern is the right-aligned version of Pattern-11.

Pattern-27 — Right-Aligned Repeated Alphabet Triangle

         A
        B B
       C C C
      D D D D
     E E E E E
    F F F F F F
   G G G G G G G
  H H H H H H H H
 I I I I I I I I I
J J J J J J J J J J

Pattern-27 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-27 — Program Explanation

The alphabet depends on the row:

chr(64+i)

Therefore:

i = 1 → A
i = 2 → B
i = 3 → C
...

The expression:

(chr(64+i)+" ")*i

repeats the current row alphabet i times.

i = 3

chr(67) = C

("C" + " ") * 3

C C C

The document also places an additional print() after the row statement, so it is retained here as provided.

Pattern-28 — Right-Aligned Increasing Alphabet Triangle

         A
        A B
       A B C
      A B C D
     A B C D E
    A B C D E F
   A B C D E F G
  A B C D E F G H
 A B C D E F G H I
A B C D E F G H I J

Pattern-28 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-28 — Program Explanation

Leading spaces:

" " * (n-i)

Number of characters:

i

The alphabet depends on j:

chr(64+j)

Therefore:

j = 1 → A
j = 2 → B
j = 3 → C
j = 4 → D

For i = 4:

A B C D

Pattern-28 is the right-aligned version of Pattern-13.

Pattern-29 — Right-Shifted Decreasing Star Triangle

Pattern-29 reverses the direction used in the previous right-aligned patterns.

* * * * *
 * * * *
  * * *
   * *
    *

Now:

Spaces increase
Stars decrease

Pattern-29 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-29 — Program Explanation

The leading-space formula is:

i - 1

The star-count formula is:

n + 1 - i

For n = 5:

i Spaces Stars
105
214
323
432
541

Therefore:

Spaces = i - 1
Stars  = n + 1 - i

Pattern-29 — Dry Run with n = 5

i = 1
spaces = 0
stars  = 5
→ * * * * *

i = 2
spaces = 1
stars  = 4
→  * * * *

i = 3
spaces = 2
stars  = 3
→   * * *

i = 4
spaces = 3
stars  = 2
→    * *

i = 5
spaces = 4
stars  = 1
→     *

Pattern-30 — Right-Shifted Decreasing Repeated Number Triangle

5 5 5 5 5
 4 4 4 4
  3 3 3
   2 2
    1

The number decreases from n to 1.

The number of repetitions also decreases.

Pattern-30 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-30 — Program Explanation

The leading spaces are:

i - 1

The current number is:

n + 1 - i

The same formula determines how many times the number is repeated:

(str(n+1-i)+" ")*(n+1-i)

For n = 5:

i = 1

Number = 5 + 1 - 1
       = 5

Repetitions = 5

5 5 5 5 5
i = 2

Number = 5 + 1 - 2
       = 4

Repetitions = 4

 4 4 4 4
i = 5

Number = 5 + 1 - 5
       = 1

Repetitions = 1

    1

Pattern-23 to Pattern-28 — Common Structure

Patterns 23–28 follow the same basic right-aligned structure.

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

    print(" "*(n-i),end="")

    # Print i values

The formulas are:

Spaces = n - i
Values = i

Only the value being printed changes.

Pattern Printed Value
23Star without spacing
24Star with spacing
25Current row number i
26Column number j
27chr(64+i)
28chr(64+j)

Pattern-29 and Pattern-30 — Common Structure

Patterns 29–30 use the opposite movement.

Spaces = i - 1
Values = n + 1 - i

Therefore:

Row increases
     │
     ├── Spaces increase
     │
     └── Values decrease
Row Spaces Values
10n
21n-1
32n-2
.........
nn-11

Right-Aligned Increasing vs Decreasing Patterns

Type Spaces Values
Increasing n-i i
Decreasing i-1 n+1-i

Increasing

Spaces: 4 3 2 1 0
Values: 1 2 3 4 5

Decreasing

Spaces: 0 1 2 3 4
Values: 5 4 3 2 1

These two formulas are very important for solving many upcoming pattern programs.

Part 3 — Complete Formula Table

Pattern Space Logic Value / Loop Logic
21 None chr(64+n+1-i)
22 None chr(65+n-j)
23 n-i "*"*i
24 n-i range(1,i+1) stars
25 n-i (str(i)+" ")*i
26 n-i j
27 n-i (chr(64+i)+" ")*i
28 n-i chr(64+j)
29 i-1 "* "*(n+1-i)
30 i-1 (str(n+1-i)+" ")*(n+1-i)

Part 3 — Execution Flow

                         START
                           │
                           ▼
                        Read n
                           │
                           ▼
                    Outer Loop (i)
                           │
                           ▼
                 Decide Pattern Type
                           │
              ┌────────────┴────────────┐
              │                         │
              ▼                         ▼
           Increasing                Decreasing
        Right-Aligned              Right-Shifted
              │                         │
              ▼                         ▼
       Spaces = n-i              Spaces = i-1
       Values = i                Values = n+1-i
              │                         │
              └────────────┬────────────┘
                           │
                           ▼
                    Print Spaces
                           │
                           ▼
                    Print Pattern
                           │
             ┌─────────────┼─────────────┐
             ▼             ▼             ▼
           Stars        Numbers       Alphabets
             │             │             │
             └─────────────┴─────────────┘
                           │
                           ▼
                      Next Line
                           │
                           ▼
                       Next Row
                           │
                           ▼
                          END

Part 3 — Important Notes

  • " "*(n-i) creates decreasing leading spaces.
  • " "*(i-1) creates increasing leading spaces.
  • For an increasing right-aligned triangle, use n-i spaces and i values.
  • For a decreasing right-shifted triangle, use i-1 spaces and n+1-i values.
  • chr(64+n+1-i) creates a decreasing row-based alphabet.
  • chr(65+n-j) creates reverse alphabets inside a row.
  • chr(64+i) creates an alphabet based on the row.
  • chr(64+j) creates alphabets based on columns.
  • String multiplication can be used instead of an inner loop when the same value must be repeated.
  • end="" prevents Python from moving to the next line while constructing the current row.

Part 3 — Summary

Pattern Pattern Type Main Concept
21 Decreasing alphabet Repeated reverse row alphabet
22 Decreasing alphabet Reverse alphabet sequence
23 Increasing right-aligned Joined stars
24 Increasing right-aligned Spaced stars
25 Increasing right-aligned Repeated row number
26 Increasing right-aligned Increasing numbers
27 Increasing right-aligned Repeated row alphabet
28 Increasing right-aligned Increasing alphabets
29 Decreasing right-shifted Stars
30 Decreasing right-shifted Repeated numbers

Part 3 — Quick Revision

                RIGHT-ALIGNED PATTERNS
                         │
          ┌──────────────┴──────────────┐
          │                             │
          ▼                             ▼
       Increasing                    Decreasing
          │                             │
          ▼                             ▼
   Spaces = n-i                  Spaces = i-1
   Values = i                    Values = n+1-i
          │                             │
          ▼                             ▼
 Spaces decrease                 Spaces increase
 Values increase                 Values decrease
          │                             │
          └──────────────┬──────────────┘
                         │
                         ▼
                 Choose What to Print
                         │
             ┌───────────┼───────────┐
             ▼           ▼           ▼
           Stars       Numbers    Alphabets
                         │
                         ▼
                 Pattern Completed

Introduction

Part 4 covers Pattern-31 to Pattern-40.

We will learn:

Pattern-31 → Right-Shifted Decreasing Number Sequence
Pattern-32 → Right-Shifted Decreasing Repeated Alphabet
Pattern-33 → Right-Shifted Decreasing Alphabet Sequence

Pattern-34 → Star Pyramid
Pattern-35 → Repeated Number Pyramid
Pattern-36 → Repeated Alphabet Pyramid
Pattern-37 → Odd Alphabet Pyramid
Pattern-38 → Palindrome Alphabet Pyramid
Pattern-39 → Reverse Odd Number Pyramid
Pattern-40 → Increasing Alphabet Pyramid

This part introduces one very important pyramid formula:

Number of Values = 2 * i - 1

For five rows:

i = 1 → 1 value
i = 2 → 3 values
i = 3 → 5 values
i = 4 → 7 values
i = 5 → 9 values

Pattern-31 — Right-Shifted Decreasing Number Sequence

Pattern-31 prints numbers starting from 1, but the number of values decreases in every row.

Output

1 2 3 4 5
 1 2 3 4
  1 2 3
   1 2
    1

Two things happen row by row:

Leading Spaces → Increase
Numbers        → Decrease

Pattern-31 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-31 — Step-by-Step Explanation

Step 1 — Read Number of Rows

n=int(input("Enter the number of rows: "))

The value of n controls the total number of rows.

Step 2 — Outer Loop

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

The variable i represents the current row.

Step 3 — Print Leading Spaces

print(" "*(i-1),end="")

The number of leading spaces is:

i - 1

Step 4 — Print Numbers

for j in range(1,n+2-i):
    print(j,end=" ")

The inner loop prints:

1 to n + 1 - i

For n = 5:

i = 1 → 1 2 3 4 5
i = 2 → 1 2 3 4
i = 3 → 1 2 3
i = 4 → 1 2
i = 5 → 1

Pattern-31 — Dry Run

i Spaces j Range Output
101 to 51 2 3 4 5
211 to 41 2 3 4
321 to 31 2 3
431 to 21 2
541 to 11

Pattern-32 — Right-Shifted Decreasing Repeated Alphabet

Output

E E E E E
 D D D D
  C C C
   B B
    A

The alphabet and its repetition count both decrease in every row.

Pattern-32 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-32 — Step-by-Step Explanation

The leading spaces are generated using:

" " * (i-1)

The current alphabet is calculated using:

chr(65+n-i)

For n = 5:

i = 1 → chr(69) → E
i = 2 → chr(68) → D
i = 3 → chr(67) → C
i = 4 → chr(66) → B
i = 5 → chr(65) → A

The repetition count is:

n + 1 - i

Therefore:

E → 5 times
D → 4 times
C → 3 times
B → 2 times
A → 1 time

Pattern-32 — Formula

Leading Spaces = i - 1

Alphabet =
chr(65 + n - i)

Repetitions =
n + 1 - i

Pattern-33 — Right-Shifted Decreasing Alphabet Sequence

Output

A B C D E
 A B C D
  A B C
   A B
    A

Every row starts from A.

The ending alphabet decreases in every next row.

Pattern-33 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-33 — Step-by-Step Explanation

First, leading spaces are printed:

" " * (i-1)

The inner loop starts from:

65

ASCII value 65 represents:

A

The loop is:

range(65,66+n-i)

For n = 5:

Row 1 → ASCII 65 to 69
      → A B C D E

Row 2 → ASCII 65 to 68
      → A B C D

Row 3 → ASCII 65 to 67
      → A B C

Row 4 → A B

Row 5 → A

Pattern-31 to Pattern-33 — Common Logic

Patterns 31–33 follow the same basic shape.

Values decrease
Spaces increase

The common formulas are:

Spaces = i - 1

Values = n + 1 - i
Pattern Printed Value
31Increasing numbers from 1
32Repeated decreasing alphabet
33Increasing alphabet sequence from A

Introduction to Pyramid Patterns

Pattern-34 starts a new category: Pyramid Patterns.

A normal pyramid follows two important formulas:

Leading Spaces = n - i

Values = 2 * i - 1

For n = 5:

i Spaces 2*i-1
141
233
325
417
509

Therefore the number of values follows the odd-number sequence:

1, 3, 5, 7, 9, ...

Pattern-34 — Star Pyramid

Pattern-34 creates a pyramid using stars.

Output

    *
   * * *
  * * * * *
 * * * * * * *
* * * * * * * * *

The source program uses:

"* " * (2*i-1)

So every row contains an odd number of stars.

Pattern-34 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-34 — Program Explanation

The expression:

" " * (n-i)

controls the leading spaces.

The expression:

"* " * (2*i-1)

controls the number of stars.

For each row:

i = 1 → 2(1)-1 = 1
i = 2 → 2(2)-1 = 3
i = 3 → 2(3)-1 = 5
i = 4 → 2(4)-1 = 7
i = 5 → 2(5)-1 = 9

Pattern-34 — Dry Run

Row Spaces Stars
141
233
325
417
509

Pattern-35 — Repeated Number Pyramid

Output

    1
   2 2 2
  3 3 3 3 3
 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5

The row number is repeated an odd number of times.

Pattern-35 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-35 — Step-by-Step Explanation

The current number is:

i

It is converted into a string:

str(i)

A space is added:

str(i) + " "

Then it is repeated:

2*i - 1

Example for i = 4:

2*4 - 1
= 7

"4 " * 7

4 4 4 4 4 4 4

Pattern-36 — Repeated Alphabet Pyramid

Output

    A
   B B B
  C C C C C
 D D D D D D D
E E E E E E E E E

The alphabet changes according to the row.

The repetition count follows:

1, 3, 5, 7, 9

Pattern-36 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-36 — Program Explanation

The alphabet formula is:

chr(64+i)

Therefore:

i = 1 → A
i = 2 → B
i = 3 → C
i = 4 → D
i = 5 → E

The repetition count is:

2*i - 1

For row 3:

Character = C

Repetitions =
2*3 - 1
= 5

C C C C C

Pattern-37 — Odd Alphabet Pyramid

Output

    A
   C C C
  E E E E E
 G G G G G G G
I I I I I I I I I

This pattern skips one alphabet after every row.

A → C → E → G → I

Pattern-37 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-37 — Character Formula Explanation

The important formula is:

chr(63 + 2*i)

For each row:

i = 1

63 + 2
= 65

chr(65)
= A
i = 2

63 + 4
= 67

chr(67)
= C
i = 3

63 + 6
= 69

chr(69)
= E

Therefore:

A, C, E, G, I

Again, the repetition count is:

2*i - 1

Pattern-38 — Palindrome Alphabet Pyramid

Pattern-38 is more advanced because every row contains an increasing and decreasing alphabet sequence.

Output

    A
   A B A
  A B C B A
 A B C D C B A
A B C D E D C B A

This is an alphabet palindrome pattern.

Each row reads the same from left to right and right to left.

Pattern-38 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-38 — First Inner Loop

The first inner loop is:

for j in range(65,65+i):
    print(chr(j),end=" ")

It prints alphabets in increasing order.

For i = 5:

65 → A
66 → B
67 → C
68 → D
69 → E

A B C D E

Pattern-38 — Second Inner Loop

The second inner loop is:

for k in range(63+i,64,-1):
    print(chr(k),end=" ")

It prints the remaining alphabets in reverse order.

For i = 5:

k starts at:

63 + 5
= 68

chr(68) = D

Then:

68 → D
67 → C
66 → B
65 → A

So the complete row becomes:

A B C D E + D C B A

A B C D E D C B A

Pattern-38 — Row-by-Row Logic

i Increasing Part Decreasing Part Complete Row
1 A - A
2 A B A A B A
3 A B C B A A B C B A
4 A B C D C B A A B C D C B A
5 A B C D E D C B A A B C D E D C B A

Pattern-39 — Reverse Odd Number Pyramid

Output

    1
   3 2 1
  5 4 3 2 1
 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1

Each row starts with an odd number and decreases until 1.

Pattern-39 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-39 — Step-by-Step Explanation

The starting number is:

2*i - 1

Therefore:

i = 1 → 1
i = 2 → 3
i = 3 → 5
i = 4 → 7
i = 5 → 9

The loop:

range(2*i-1,0,-1)

counts backward until 1.

For i = 4:

2*4 - 1
= 7

range(7,0,-1)

7 6 5 4 3 2 1

Pattern-39 — Dry Run

i Starting Value Output
111
233 2 1
355 4 3 2 1
477 6 5 4 3 2 1
599 8 7 6 5 4 3 2 1

Pattern-40 — Increasing Alphabet Pyramid

Output

    A
   A B C
  A B C D E
 A B C D E F G
A B C D E F G H I

Every row starts from A.

The number of alphabets follows:

1, 3, 5, 7, 9

Pattern-40 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-40 — Step-by-Step Explanation

The alphabet loop is:

for j in range(65,65+2*i-1):

The loop always starts at ASCII:

65 → A

The number of iterations is:

2*i - 1

For row 3:

2*3 - 1
= 5

Therefore five alphabets are printed:

A B C D E

For row 5:

2*5 - 1
= 9

A B C D E F G H I

Pattern-34 to Pattern-40 — Pyramid Comparison

Pattern Pyramid Content Main Formula
34 Stars 2*i-1 stars
35 Repeated row number i repeated 2*i-1 times
36 Repeated row alphabet chr(64+i)
37 Odd-position alphabet chr(63+2*i)
38 Alphabet palindrome Increasing + decreasing alphabets
39 Reverse numbers 2*i-1 down to 1
40 Increasing alphabets 2*i-1 alphabets

Understanding the 2*i-1 Formula

The expression:

2*i - 1

generates consecutive odd numbers.

i Calculation Result
12 × 1 - 11
22 × 2 - 13
32 × 3 - 15
42 × 4 - 17
52 × 5 - 19

This formula is useful because a pyramid normally grows symmetrically:

        1
      3 values
    5 values
  7 values
9 values

Part 4 — Complete Formula Table

Pattern Leading Spaces Main Logic
31 i-1 j = 1 to n+1-i
32 i-1 chr(65+n-i) repeated n+1-i
33 i-1 A to decreasing endpoint
34 n-i 2*i-1 stars
35 n-i i repeated 2*i-1
36 n-i chr(64+i) repeated 2*i-1
37 n-i chr(63+2*i) repeated 2*i-1
38 n-i Increasing + decreasing alphabet
39 n-i 2*i-1 down to 1
40 n-i Print 2*i-1 alphabets from A

Part 4 — Execution Flow

                         START
                           │
                           ▼
                        Read n
                           │
                           ▼
                    Outer Loop (i)
                           │
                           ▼
                  Identify Pattern
                           │
              ┌────────────┴────────────┐
              │                         │
              ▼                         ▼
        Pattern 31-33              Pattern 34-40
              │                         │
              ▼                         ▼
       Decreasing Shape               Pyramid
              │                         │
              ▼                         ▼
     Spaces = i - 1             Spaces = n - i
              │                         │
              ▼                         ▼
 Values = n + 1 - i          Values usually = 2*i-1
              │                         │
              └────────────┬────────────┘
                           │
                           ▼
                    Print Spaces
                           │
                           ▼
                   Generate Values
                           │
              ┌────────────┼────────────┐
              ▼            ▼            ▼
           Stars        Numbers      Alphabets
              │            │            │
              └────────────┴────────────┘
                           │
                           ▼
                      Print Row
                           │
                           ▼
                       Next Row
                           │
                           ▼
                          END

Part 4 — Important Notes

  • Patterns 31–33 use increasing leading spaces and decreasing values.
  • The common space formula for Patterns 31–33 is i-1.
  • Pattern-31 always starts its number sequence from 1.
  • Pattern-32 uses chr(65+n-i) to generate decreasing alphabets.
  • Pattern-33 always starts its alphabet sequence from A.
  • Pattern-34 begins the pyramid-pattern section.
  • The most important pyramid formula is 2*i-1.
  • 2*i-1 generates the sequence 1, 3, 5, 7, 9, ....
  • The common leading-space formula for these increasing pyramids is n-i.
  • Pattern-37 uses chr(63+2*i) to generate A, C, E, G, I....
  • Pattern-38 requires two inner loops because it first increases alphabets and then decreases them.
  • Pattern-39 uses a negative step -1 to print numbers in reverse order.
  • Pattern-40 combines ASCII values with the 2*i-1 pyramid formula.

Part 4 — Summary

Pattern Output Type Key Concept
31 Decreasing numbers Increasing spaces
32 Repeated decreasing alphabet ASCII + repetition
33 Decreasing alphabet sequence ASCII range
34 Star pyramid 2*i-1 stars
35 Number pyramid Repeated row number
36 Alphabet pyramid Repeated row alphabet
37 Odd alphabet pyramid A, C, E, G, I
38 Palindrome alphabet pyramid Forward + backward loops
39 Reverse number pyramid Odd number to 1
40 Alphabet pyramid 2*i-1 alphabets

Part 4 — Quick Revision

                    PATTERN 31-40
                          │
          ┌───────────────┴───────────────┐
          │                               │
          ▼                               ▼
     Pattern 31-33                   Pattern 34-40
          │                               │
          ▼                               ▼
 Decreasing Right-Shifted               Pyramid
          │                               │
          ▼                               ▼
 Spaces = i - 1                   Spaces = n - i
          │                               │
          ▼                               ▼
Values = n + 1 - i              Values ≈ 2*i - 1
          │                               │
     ┌────┴────┐             ┌────────────┼────────────┐
     ▼         ▼             ▼            ▼            ▼
  Numbers   Alphabets      Stars       Numbers      Alphabets
                                                    │
                                      ┌─────────────┼─────────────┐
                                      ▼             ▼             ▼
                                   Repeated     Palindrome     Sequence

Introduction

Part 5 covers Pattern-41 to Pattern-50.

In this part, we will learn:

Pattern-41 → Reverse Alphabet Pyramid
Pattern-42 → Reverse-to-Forward Number Pyramid
Pattern-43 → Reverse-to-Forward Alphabet Pyramid
Pattern-44 → Palindrome Number Pyramid
Pattern-45 → Repeated Increasing Alphabet Pyramid
Pattern-46 → Descending Number Triangle
Pattern-47 → Inverted Star Pyramid
Pattern-48 → Inverted Repeated Number Pyramid
Pattern-49 → Inverted Odd Number Pyramid
Pattern-50 → Inverted Number Sequence Pattern

Important concepts used in this part are:

  • Nested loops
  • Increasing and decreasing ranges
  • Negative step in range()
  • ASCII values with chr()
  • Leading spaces
  • Odd-number formulas
  • Two inner loops in the same row
  • Increasing and inverted pyramids

Pattern-41 — Reverse Alphabet Pyramid

Pattern-41 prints alphabets in reverse order.

The starting alphabet increases by two positions in every row.

Output

    A
   C B A
  E D C B A
 G F E D C B A
I H G F E D C B A

Observe the first alphabet of every row:

A
C
E
G
I

These are alternate alphabets.

After selecting the starting alphabet, the program prints backward until A.

Pattern-41 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-41 — Step-by-Step Explanation

Step 1 — Read Number of Rows

n=int(input("Enter the number of rows: "))

The variable n stores the number of rows.

Step 2 — Outer Loop

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

The outer loop controls the rows.

Step 3 — Print Leading Spaces

print(" "*(n-i),end="")

The number of spaces decreases in every row.

n = 5

i = 1 → 4 spaces
i = 2 → 3 spaces
i = 3 → 2 spaces
i = 4 → 1 space
i = 5 → 0 spaces

Step 4 — Calculate Starting Alphabet

65 + 2*i - 2

For different rows:

i = 1 → 65 → A
i = 2 → 67 → C
i = 3 → 69 → E
i = 4 → 71 → G
i = 5 → 73 → I

Step 5 — Print in Reverse Order

range(65+2*i-2,64,-1)

The value decreases by 1 until ASCII value 65.

For row 4:

Starting ASCII = 71

71 → G
70 → F
69 → E
68 → D
67 → C
66 → B
65 → A

Therefore:

G F E D C B A

Pattern-41 — Dry Run

i Start ASCII Start Character Output
165AA
267CC B A
369EE D C B A
471GG F E D C B A
573II H G F E D C B A

Pattern-42 — Reverse-to-Forward Number Pyramid

Pattern-42 creates a number pyramid using two parts.

The first part prints numbers in decreasing order and the second part prints numbers in increasing order.

Output

    0
   1 0 1
  2 1 0 1 2
 3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4

The center value of every row is:

0

The values are symmetrical around 0.

Pattern-42 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-42 — First Inner Loop

The first inner loop is:

for j in range(1,i):
    print(i-j,end=" ")

It prints decreasing values before 0.

For i = 5:

j = 1 → 5-1 = 4
j = 2 → 5-2 = 3
j = 3 → 5-3 = 2
j = 4 → 5-4 = 1

Output:

4 3 2 1

Pattern-42 — Second Inner Loop

The second inner loop is:

for k in range(0,i):
    print(k,end=" ")

It prints:

0 1 2 ... i-1

For i = 5:

0 1 2 3 4

Combining both loops:

4 3 2 1 + 0 1 2 3 4

4 3 2 1 0 1 2 3 4

Pattern-42 — Row-by-Row Logic

Row Left Part Right Part Complete Output
1-00
210 11 0 1
32 10 1 22 1 0 1 2
43 2 10 1 2 33 2 1 0 1 2 3
54 3 2 10 1 2 3 44 3 2 1 0 1 2 3 4

Pattern-43 — Reverse-to-Forward Alphabet Pyramid

Pattern-43 is the alphabet version of Pattern-42.

Output

    A
   B A B
  C B A B C
 D C B A B C D
E D C B A B C D E

The pattern decreases toward A and then increases again.

Pattern-43 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-43 — Step-by-Step Explanation

First Part

for j in range(1,i):
    print(chr(i-j+65),end=" ")

This prints alphabets in decreasing order.

For i = 5:

j = 1 → chr(69) → E
j = 2 → chr(68) → D
j = 3 → chr(67) → C
j = 4 → chr(66) → B

First part:

E D C B

Second Part

for k in range(0,i):
    print(chr(k+65),end=" ")

For i = 5:

k = 0 → A
k = 1 → B
k = 2 → C
k = 3 → D
k = 4 → E

Second part:

A B C D E

Complete row:

E D C B A B C D E

Pattern-42 vs Pattern-43

Feature Pattern-42 Pattern-43
Data TypeNumbersAlphabets
Center0A
Left SideDecreasing numbersDecreasing alphabets
Right SideIncreasing numbersIncreasing alphabets
Character ConversionNot requiredchr()

Pattern-44 — Palindrome Number Pyramid

Output

    1
   1 2 1
  1 2 3 2 1
 1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1

Every row first increases from 1 to the row number and then decreases back to 1.

Therefore every row forms a numeric palindrome.

Pattern-44 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-44 — Increasing Part

The first loop is:

for j in range(1,i+1):
    print(j,end=" ")

For row 5:

1 2 3 4 5

Pattern-44 — Decreasing Part

The second loop is:

for k in range(i-1,0,-1):
    print(k,end=" ")

The loop starts from:

i - 1

This prevents the highest value from being printed twice.

For row 5:

4 3 2 1

Complete row:

1 2 3 4 5 4 3 2 1

Pattern-44 — Dry Run

i Increasing Part Decreasing Part Output
11-1
21 211 2 1
31 2 32 11 2 3 2 1
41 2 3 43 2 11 2 3 4 3 2 1
51 2 3 4 54 3 2 11 2 3 4 5 4 3 2 1

Pattern-45 — Repeated Increasing Alphabet Pyramid

Output

    A
   A B A
  A B C A B
 A B C D A B C
A B C D E A B C D

Each row contains two alphabet sequences.

The first sequence prints from A to the current row alphabet.

The second sequence again starts from A, but stops one alphabet earlier.

Pattern-45 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-45 — First Alphabet Sequence

for j in range(1,i+1):
    print(chr(64+j),end=" ")

For row 5:

j = 1 → A
j = 2 → B
j = 3 → C
j = 4 → D
j = 5 → E

Result:

A B C D E

Pattern-45 — Second Alphabet Sequence

for k in range(1,i):
    print(chr(64+k),end=" ")

For row 5:

A B C D

Therefore the complete row is:

A B C D E A B C D

The second loop uses:

range(1,i)

instead of:

range(1,i+1)

Therefore it prints one fewer alphabet.

Pattern-46 — Descending Number Triangle

Pattern-46 prints numbers starting from n and decreases toward smaller values.

The number of values increases row by row.

Program Logic Output for n = 5

    5
   5 4
  5 4 3
 5 4 3 2
5 4 3 2 1

Pattern-46 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-46 — Step-by-Step Explanation

The value printed is calculated using:

n + 1 - j

If n = 5:

j = 1 → 5+1-1 = 5
j = 2 → 5+1-2 = 4
j = 3 → 5+1-3 = 3
j = 4 → 5+1-4 = 2
j = 5 → 5+1-5 = 1

But the inner loop executes only i times:

range(1,i+1)

Therefore:

Row 1 → 5
Row 2 → 5 4
Row 3 → 5 4 3
Row 4 → 5 4 3 2
Row 5 → 5 4 3 2 1

Pattern-46 — Formula

Leading Spaces = n - i

Number of Values = i

Printed Value = n + 1 - j

Pattern-47 — Inverted Star Pyramid

Pattern-47 begins the inverted/decreasing pyramid section.

Output

* * * * * * * * *
 * * * * * * *
  * * * * *
   * * *
    *

The number of stars follows:

9
7
5
3
1

At the same time, leading spaces increase.

Pattern-47 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-47 — First Star Loop

for j in range(1,num+2-i):
    print("*",end=" ")

The first loop prints:

num + 1 - i

stars.

For num = 5:

i = 1 → 5 stars
i = 2 → 4 stars
i = 3 → 3 stars
i = 4 → 2 stars
i = 5 → 1 star

Pattern-47 — Second Star Loop

for k in range(1,num+1-i):
    print("*",end=" ")

The second loop prints:

num - i

additional stars.

Therefore the total is:

(num + 1 - i) + (num - i)

= 2*num + 1 - 2*i

For num = 5:

i = 1 → 9 stars
i = 2 → 7 stars
i = 3 → 5 stars
i = 4 → 3 stars
i = 5 → 1 star

Pattern-47 — Dry Run

i Spaces First Loop Second Loop Total Stars
10549
21437
32325
43213
54101

Pattern-48 — Inverted Repeated Number Pyramid

Output

5 5 5 5 5 5 5 5 5
 4 4 4 4 4 4 4
  3 3 3 3 3
   2 2 2
    1

The row value decreases:

5 → 4 → 3 → 2 → 1

The number of repetitions also decreases:

9 → 7 → 5 → 3 → 1

Pattern-48 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-48 — Printed Number

The number printed in each row is:

num + 1 - i

For num = 5:

i = 1 → 5
i = 2 → 4
i = 3 → 3
i = 4 → 2
i = 5 → 1

Pattern-48 — Repetition Logic

Two loops print the same number.

First Loop

for j in range(0,num+1-i):

Second Loop

for k in range(1,num+1-i):

Together they generate:

2*num + 1 - 2*i

values.

Therefore:

Row 1 → 9 copies of 5
Row 2 → 7 copies of 4
Row 3 → 5 copies of 3
Row 4 → 3 copies of 2
Row 5 → 1 copy of 1

Pattern-49 — Inverted Odd Number Pyramid

Output

9 9 9 9 9 9 9 9 9
 7 7 7 7 7 7 7
  5 5 5 5 5
   3 3 3
    1

This pattern prints decreasing odd numbers.

9
7
5
3
1

The number itself is also repeated the same number of times.

Pattern-49 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-49 — Odd Number Formula

The most important expression is:

2*num + 1 - 2*i

For num = 5:

i = 1

2*5 + 1 - 2*1
= 10 + 1 - 2
= 9
i = 2

11 - 4
= 7
i = 3

11 - 6
= 5
i = 4

11 - 8
= 3
i = 5

11 - 10
= 1

Therefore the values are:

9, 7, 5, 3, 1

Pattern-49 — Complete Row Logic

i Spaces Value Repetitions
1099
2177
3255
4333
5411

Pattern-50 — Inverted Number Sequence Pattern

Pattern-50 prints an inverted sequence of numbers.

Output

1 2 3 4 5 6 7
 1 2 3 4 5
  1 2 3
   1

The number of printed values decreases by two after every row.

7 → 5 → 3 → 1

This pattern uses two inner loops to construct every row.

Pattern-50 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-50 — First Inner Loop

The first inner loop is:

for j in range(1,num+2-i):
    print(j,end=" ")

It prints an increasing sequence starting from 1.

For example, when num = 4:

i = 1 → 1 2 3 4
i = 2 → 1 2 3
i = 3 → 1 2
i = 4 → 1

Pattern-50 — Second Inner Loop

The second inner loop is:

for k in range(2,num+2-i):
    print(num+k-i,end=" ")

It prints the remaining increasing numbers required to complete the row.

For num = 4 and i = 1:

First loop:
1 2 3 4

Second loop:

k = 2 → 4 + 2 - 1 = 5
k = 3 → 4 + 3 - 1 = 6
k = 4 → 4 + 4 - 1 = 7

Therefore:

1 2 3 4 5 6 7

For row 2:

First loop:
1 2 3

Second loop:
4 5

Complete:
1 2 3 4 5

For row 3:

1 2 3

For row 4:

1

Pattern-50 — Dry Run

For num = 4:

i Spaces First Loop Second Loop Complete Row
1 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7
2 1 1 2 3 4 5 1 2 3 4 5
3 2 1 2 3 1 2 3
4 3 1 - 1

Pattern-41 to Pattern-46 — Increasing Pyramid Comparison

Pattern Type Main Logic
41 Reverse Alphabet Odd-position alphabet down to A
42 Number Symmetry Decrease to 0, then increase
43 Alphabet Symmetry Decrease to A, then increase
44 Number Palindrome Increase and then decrease
45 Repeated Alphabet Sequence Two increasing alphabet loops
46 Descending Numbers Start from n and decrease

Pattern-47 to Pattern-50 — Inverted Pattern Comparison

Pattern Type Row Size
47 Stars 9, 7, 5, 3, 1
48 Repeated Numbers 9, 7, 5, 3, 1
49 Repeated Odd Numbers 9, 7, 5, 3, 1
50 Increasing Number Sequence 7, 5, 3, 1 for num = 4

Important Formulas in Part 5

Increasing Pyramid Spaces

n - i

Used in Patterns 41–46.

Inverted Pyramid Spaces

i - 1

Used in Patterns 47–50.

Pattern-41 Starting Alphabet

65 + 2*i - 2

Pattern-46 Printed Number

n + 1 - j

Inverted Odd Row Size

2*num + 1 - 2*i

For num = 5, this generates:

9, 7, 5, 3, 1

Pattern-49 Printed Value

2*num + 1 - 2*i

Understanding Increasing vs Inverted Pyramid

Increasing Pyramid

Leading spaces decrease while values increase.

    *
   * * *
  * * * * *
 * * * * * * *
* * * * * * * * *

Typical space formula:

n - i

Inverted Pyramid

Leading spaces increase while values decrease.

* * * * * * * * *
 * * * * * * *
  * * * * *
   * * *
    *

Typical space formula:

i - 1

This relationship is very important when solving pattern-programming questions.

Part 5 — Execution Flow

                         START
                           │
                           ▼
                      Read n / num
                           │
                           ▼
                       Outer Loop
                           │
                           ▼
                 Calculate Row Number
                           │
                           ▼
                    Print Spaces
                           │
             ┌─────────────┴─────────────┐
             │                           │
             ▼                           ▼
      Increasing Pyramid          Inverted Pyramid
       Pattern 41-46              Pattern 47-50
             │                           │
             ▼                           ▼
      Spaces Decrease              Spaces Increase
         n - i                       i - 1
             │                           │
             ▼                           ▼
      Values Increase              Values Decrease
             │                           │
             └─────────────┬─────────────┘
                           │
                           ▼
                  Execute Inner Loop
                           │
                    ┌──────┴──────┐
                    ▼             ▼
               First Part     Second Part
                    │             │
                    └──────┬──────┘
                           ▼
                       Print Row
                           │
                           ▼
                       Next Row
                           │
                           ▼
                          END

Part 5 — Important Notes

  • Pattern-41 uses ASCII values to generate alternate starting alphabets A, C, E, G, I.
  • A negative step such as -1 is used when values must move backward.
  • Pattern-42 combines decreasing and increasing number sequences.
  • Pattern-43 applies the same idea using alphabets.
  • Pattern-44 is a proper number palindrome because the second half is the reverse of the first half without repeating the center value.
  • Pattern-45 uses two increasing alphabet loops.
  • Pattern-46 always begins its sequence from n.
  • Pattern-47 starts the inverted pyramid patterns in this section.
  • In an inverted pyramid, spaces generally increase while the number of values decreases.
  • Patterns 47–49 use two loops to create odd-sized rows.
  • The sequence 9, 7, 5, 3, 1 can be generated using 2*num+1-2*i when num = 5.
  • Pattern-48 repeats the value num+1-i.
  • Pattern-49 uses the same odd-number formula both for the printed value and the effective row width.
  • Pattern-50 creates decreasing odd-sized rows of consecutive numbers.
  • end="" is important when spaces and pattern values must continue on the same line.
  • print() after the inner loops moves the cursor to the next row.

Part 5 — Summary

Pattern Pattern Type Key Concept
41 Reverse Alphabet Pyramid ASCII + reverse range
42 Number Symmetry Pyramid Decrease → 0 → Increase
43 Alphabet Symmetry Pyramid Decrease → A → Increase
44 Number Palindrome Forward + backward loops
45 Repeated Alphabet Sequence Two forward loops
46 Descending Number Triangle n+1-j
47 Inverted Star Pyramid Odd decreasing width
48 Inverted Number Pyramid Repeated decreasing value
49 Inverted Odd Number Pyramid 2*num+1-2*i
50 Inverted Number Sequence Two increasing number loops

Part 5 — Quick Revision

                     PATTERN 41-50
                           │
          ┌────────────────┴────────────────┐
          │                                 │
          ▼                                 ▼
     Pattern 41-46                    Pattern 47-50
   Advanced Pyramids                Inverted Patterns
          │                                 │
     Spaces = n-i                      Spaces = i-1
          │                                 │
     ┌────┼────────────┐              ┌─────┼───────────┐
     ▼    ▼            ▼              ▼     ▼           ▼
 Alphabet Number   Palindrome        Star  Number   Sequence
     │    │            │              │     │           │
     │    │            │              │     │           │
    41   42,46         44             47    48,49        50
     │
     ├── Pattern 43 → Alphabet Symmetry
     │
     └── Pattern 45 → Repeated Alphabet Sequence

Introduction

Part 6 covers Pattern-51 to Pattern-60.

In this part, we will learn:

Pattern-51 → Inverted Repeated Alphabet Pyramid
Pattern-52 → Inverted Odd-Position Alphabet Pyramid
Pattern-53 → Inverted Alphabet Sequence
Pattern-54 → Palindrome Number Pyramid
Pattern-55 → Palindrome Alphabet Pyramid
Pattern-56 → Zero-Centered Symmetrical Number Pyramid
Pattern-57 → Combined Number Diamond Pattern
Pattern-58 → Combined Alphabet Diamond Pattern
Pattern-59 → Increasing and Decreasing Star Pattern
Pattern-60 → Increasing and Decreasing Reverse Number Pattern

Important concepts used in this part are:

  • Nested for loops
  • Increasing and decreasing row sizes
  • Leading spaces
  • ASCII values and chr()
  • Odd-width inverted pyramids
  • Palindrome patterns
  • Two-part symmetrical rows
  • Combining increasing and decreasing patterns
  • Multiple outer loops

Pattern-51 — Inverted Repeated Alphabet Pyramid

Pattern-51 is an inverted pyramid containing repeated alphabets.

Output

E E E E E E E E E
 D D D D D D D
  C C C C C
   B B B
    A

The alphabet decreases row by row:

E → D → C → B → A

The number of repetitions also decreases:

9 → 7 → 5 → 3 → 1

Pattern-51 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-51 — Step-by-Step Explanation

Step 1 — Outer Loop

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

The outer loop controls the rows.

Step 2 — Leading Spaces

print(" "*(i-1),end="")

The spaces increase row by row.

i = 1 → 0 spaces
i = 2 → 1 space
i = 3 → 2 spaces
i = 4 → 3 spaces
i = 5 → 4 spaces

Step 3 — Find the Alphabet

chr(65+num-i)

For num = 5:

i = 1 → chr(69) → E
i = 2 → chr(68) → D
i = 3 → chr(67) → C
i = 4 → chr(66) → B
i = 5 → chr(65) → A

Step 4 — Repeat the Alphabet

The two inner loops together generate odd row sizes:

9, 7, 5, 3, 1

Pattern-51 — Dry Run

i Alphabet Spaces Repetitions
1E09
2D17
3C25
4B33
5A41

Pattern-52 — Inverted Odd-Position Alphabet Pyramid

Pattern-52 is similar to Pattern-51, but it uses alternate alphabets.

Output

I I I I I I I I I
 G G G G G G G
  E E E E E
   C C C
    A

The alphabets are:

I → G → E → C → A

These correspond to odd alphabet positions:

9 → 7 → 5 → 3 → 1

Pattern-52 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-52 — Alphabet Formula

The main formula is:

65 + 2*num - 2*i

For num = 5:

i = 1 → 65 + 10 - 2  = 73 → I
i = 2 → 65 + 10 - 4  = 71 → G
i = 3 → 65 + 10 - 6  = 69 → E
i = 4 → 65 + 10 - 8  = 67 → C
i = 5 → 65 + 10 - 10 = 65 → A

Therefore:

I
G
E
C
A

Pattern-51 vs Pattern-52

Feature Pattern-51 Pattern-52
Alphabet Sequence E, D, C, B, A I, G, E, C, A
Alphabet Step Decrease by 1 Decrease by 2
Row Width 9, 7, 5, 3, 1 9, 7, 5, 3, 1
Spaces Increase Increase

Pattern-53 — Inverted Alphabet Sequence

Pattern-53 prints increasing alphabet sequences inside an inverted pattern.

Output

A B C D E F G
 A B C D E
  A B C
   A

The row lengths decrease by two:

7 → 5 → 3 → 1

Every row begins with A.

Pattern-53 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-53 — First Inner Loop

for j in range(1,num+2-i):
    print(chr(64+j),end=" ")

The first loop always starts from:

chr(65) → A

For num = 4:

Row 1 → A B C D
Row 2 → A B C
Row 3 → A B
Row 4 → A

Pattern-53 — Second Inner Loop

for k in range(2,num+2-i):
    print(chr(68+k-i),end=" ")

The second loop continues the alphabet sequence required to complete each row.

For the first row:

First Loop  → A B C D
Second Loop → E F G

Complete Row:
A B C D E F G

The final row contains only:

A

Pattern-54 — Palindrome Number Pyramid

Pattern-54 prints a centered number palindrome.

Output

    1
   1 2 1
  1 2 3 2 1
 1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1

Each row contains two parts:

Increasing Part + Decreasing Part

For example:

1 2 3 4 5 + 4 3 2 1

becomes:

1 2 3 4 5 4 3 2 1

Pattern-54 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-54 — Increasing Part

for j in range(1,i+1):
    print(j,end=" ")

The first loop prints from 1 to i.

For row 4:

1 2 3 4

Pattern-54 — Decreasing Part

for k in range(i-1,0,-1):
    print(k,end=" ")

The second loop begins from i-1.

For row 4:

3 2 1

It starts from i-1 so that the center number is not repeated.

Complete row:

1 2 3 4 3 2 1

Pattern-54 — Dry Run

i Spaces Increasing Decreasing Complete Row
141-1
231 211 2 1
321 2 32 11 2 3 2 1
411 2 3 43 2 11 2 3 4 3 2 1
501 2 3 4 54 3 2 11 2 3 4 5 4 3 2 1

Pattern-55 — Palindrome Alphabet Pyramid

Pattern-55 is the alphabet version of the palindrome pyramid.

Output

    A
   A B A
  A B C B A
 A B C D C B A
A B C D E D C B A

Every row first moves forward through the alphabet and then moves backward.

For example:

A B C D E D C B A

Pattern-55 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-55 — Forward Alphabet Loop

for j in range(65,65+i):
    print(chr(j),end=" ")

ASCII value 65 represents A.

For i = 5:

65 → A
66 → B
67 → C
68 → D
69 → E

Output:

A B C D E

Pattern-55 — Reverse Alphabet Loop

for k in range(63+i,64,-1):
    print(chr(k),end=" ")

For i = 5:

68 → D
67 → C
66 → B
65 → A

Output:

D C B A

Combining both:

A B C D E D C B A

Pattern-54 vs Pattern-55

Feature Pattern-54 Pattern-55
Data Numbers Alphabets
Direction Increase then decrease Forward then reverse
Palindrome Yes Yes
Uses chr() No Yes
Leading Spaces num-i num-i

Pattern-56 — Zero-Centered Symmetrical Number Pyramid

Pattern-56 creates a symmetrical number pyramid around 0.

Output

    0
   1 0 1
  2 1 0 1 2
 3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4

The left side decreases toward 0.

The right side increases away from 0.

Pattern-56 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-56 — Left Side

for j in range(1,i):
    print(i-j,end=" ")

For i = 5:

j = 1 → 4
j = 2 → 3
j = 3 → 2
j = 4 → 1

Left side:

4 3 2 1

Pattern-56 — Right Side

for k in range(0,i):
    print(k,end=" ")

For i = 5:

0 1 2 3 4

Complete row:

4 3 2 1 0 1 2 3 4

The value 0 becomes the center of every row.

Pattern-56 — Dry Run

i Left Side Right Side Complete Row
1-00
210 11 0 1
32 10 1 22 1 0 1 2
43 2 10 1 2 33 2 1 0 1 2 3
54 3 2 10 1 2 3 44 3 2 1 0 1 2 3 4

Pattern-57 — Combined Number Diamond Pattern

Pattern-57 introduces a new concept: combining two pattern sections.

Output

   3
  2 3
 1 2 3
0 1 2 3
 1 2 3
  2 3
   3

The pattern contains:

Upper Part
    +
Lower Part

The upper part grows, while the lower part shrinks.

Pattern-57 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-57 — Upper Part

for i in range(1,num+1):
    print(" "*(num-i),end="")
    for j in range(0,i):
        print(num+j-i,end=" ")
    print()

For num = 4:

i = 1 → 3
i = 2 → 2 3
i = 3 → 1 2 3
i = 4 → 0 1 2 3

The number of values increases in every row.

Pattern-57 — Lower Part

for k in range(1,num):
    print(" "*k,end="")
    for l in range(1,num+1-k):
        print(l+k-1,end=" ")
    print()

The second outer loop creates the decreasing half.

For num = 4:

k = 1 → 1 2 3
k = 2 → 2 3
k = 3 → 3

Notice that the middle row:

0 1 2 3

is printed only once.

Pattern-57 — Complete Construction

Upper Part:

   3
  2 3
 1 2 3
0 1 2 3

Lower Part:

 1 2 3
  2 3
   3

Combined:

   3
  2 3
 1 2 3
0 1 2 3
 1 2 3
  2 3
   3

Pattern-58 — Combined Alphabet Diamond Pattern

Pattern-58 applies the same combined-pattern logic using alphabets.

Output

    E
   D E
  C D E
 B C D E
A B C D E
 B C D E
  C D E
   D E
    E

The pattern expands until:

A B C D E

and then contracts again.

Pattern-58 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-58 — Upper Half

The main alphabet formula is:

chr(65 + num + j - i)

For num = 5:

Row 1 → E
Row 2 → D E
Row 3 → C D E
Row 4 → B C D E
Row 5 → A B C D E

The starting alphabet moves backward:

E → D → C → B → A

but each row moves forward toward E.

Pattern-58 — Lower Half

The lower half uses:

chr(65+k+l)

For num = 5:

k = 1 → B C D E
k = 2 → C D E
k = 3 → D E
k = 4 → E

Therefore the complete pattern becomes symmetrical vertically.

Pattern-57 vs Pattern-58

Feature Pattern-57 Pattern-58
Data Numbers Alphabets
Structure Upper + Lower Upper + Lower
Leading Spaces Used Used
Middle Row 0 1 2 3 A B C D E
Uses chr() No Yes

Pattern-59 — Increasing and Decreasing Star Pattern

Pattern-59 combines an increasing star triangle and a decreasing star triangle.

Output for num = 5

*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*

The number of stars follows:

1
2
3
4
5
4
3
2
1

Pattern-59 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-59 — Increasing Part

for i in range(1,num+1):
    for j in range(1,i+1):
        print("*",end=" ")
    print()

The number of stars equals i.

For num = 5:

i = 1 → *
i = 2 → * *
i = 3 → * * *
i = 4 → * * * *
i = 5 → * * * * *

Pattern-59 — Decreasing Part

for a in range(1,num+1):
    for k in range(1,num+1-a):
        print("*",end=" ")
    print()

The number of stars decreases after the maximum row.

4
3
2
1

Therefore the visible pattern grows and then shrinks.

Pattern-59 — Row Count

Ignoring the final empty iteration produced by the second outer loop, the visible number of rows is:

num + (num - 1)

= 2*num - 1

For num = 5:

2*5 - 1
= 9 visible rows

Pattern-60 — Increasing and Decreasing Reverse Number Pattern

Pattern-60 uses the same upper-and-lower structure as Pattern-59, but prints descending numbers.

Output for num = 5

4
4 3
4 3 2
4 3 2 1
4 3 2 1 0
4 3 2 1
4 3 2
4 3
4

Every row begins with:

num - 1

For num = 5, every row starts with 4.

Pattern-60 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-60 — Upper Part

The upper part uses:

num - j

For num = 5:

j = 1 → 4
j = 2 → 3
j = 3 → 2
j = 4 → 1
j = 5 → 0

Because the inner loop runs only i times, the rows become:

4
4 3
4 3 2
4 3 2 1
4 3 2 1 0

Pattern-60 — Lower Part

The lower part uses:

for a in range(1,num+1):
    for k in range(1,num+1-a):
        print(num-k,end=" ")

The number of printed values decreases in every row.

4 3 2 1
4 3 2
4 3
4

Therefore the complete structure expands and then contracts.

Pattern-59 vs Pattern-60

Feature Pattern-59 Pattern-60
Printed Data * Numbers
Upper Half Increasing Increasing row length
Lower Half Decreasing Decreasing row length
Maximum Width num stars num numbers
Main Formula Loop count num-j

Pattern-51 to Pattern-53 — Inverted Alphabet Family

Pattern Output Type Main Idea
51 Repeated Alphabets E → D → C → B → A
52 Odd-Position Alphabets I → G → E → C → A
53 Alphabet Sequence A B C ... with decreasing width

Pattern-54 to Pattern-56 — Symmetrical Pyramid Family

Pattern Type Center
54 Number Palindrome Current row number
55 Alphabet Palindrome Current row alphabet
56 Number Symmetry 0

The common idea is:

Left Part + Center + Right Part

Pattern-57 to Pattern-60 — Combined Pattern Family

Pattern Data Structure
57 Numbers Spaced upper + lower
58 Alphabets Spaced upper + lower
59 Stars Increasing + decreasing
60 Reverse Numbers Increasing + decreasing

Understanding Two Types of Symmetry

1. Horizontal Symmetry Inside a Row

Patterns 54, 55 and 56 create symmetry inside individual rows.

Pattern-54:
1 2 3 4 3 2 1

Pattern-55:
A B C D C B A

Pattern-56:
3 2 1 0 1 2 3

2. Vertical Symmetry Between Rows

Patterns 57–60 create a top part and a bottom part.

Increase
   │
   ▼
Maximum Row
   │
   ▼
Decrease

This produces vertical symmetry in the complete pattern.

Important Formulas in Part 6

Inverted Pyramid Leading Spaces

i - 1

Used in Patterns 51–53.

Increasing Pyramid Leading Spaces

num - i

Used in Patterns 54–58 upper sections.

Pattern-51 Alphabet

chr(65 + num - i)

Pattern-52 Alternate Alphabet

chr(65 + 2*num - 2*i)

Pattern-54 Reverse Side

range(i-1, 0, -1)

Pattern-55 Forward Alphabet Range

range(65, 65+i)

Pattern-55 Reverse Alphabet Range

range(63+i, 64, -1)

Pattern-56 Left-Side Value

i - j

Pattern-57 Upper Value

num + j - i

Pattern-58 Upper Alphabet

chr(65 + num + j - i)

Pattern-60 Printed Number

num - j

How to Solve Combined Patterns

When a pattern first grows and then shrinks, divide the problem into two sections.

Section 1 — Upper Part

for i in range(...):
    # print increasing rows

Section 2 — Lower Part

for i in range(...):
    # print decreasing rows

General structure:

          Small Row
             │
             ▼
          Bigger Row
             │
             ▼
          Biggest Row
             │
             ▼
          Smaller Row
             │
             ▼
          Small Row

This technique is used heavily from Pattern-57 onward.

Part 6 — Execution Flow

                         START
                           │
                           ▼
                       Read num
                           │
                           ▼
                Identify Pattern Type
                           │
          ┌────────────────┼────────────────┐
          │                │                │
          ▼                ▼                ▼
      Inverted         Palindrome         Combined
      Alphabet         / Symmetry         Pattern
      51 - 53           54 - 56           57 - 60
          │                │                │
          ▼                ▼                ▼
    Spaces Grow       Print Left       Print Upper
          │                │                │
          ▼                ▼                ▼
   Width Shrinks      Print Center     Maximum Row
          │                │                │
          ▼                ▼                ▼
 Print Alphabet       Print Right      Print Lower
          │                │                │
          └────────────────┼────────────────┘
                           │
                           ▼
                        New Line
                           │
                           ▼
                        Next Row
                           │
                           ▼
                          END

Part 6 — Important Notes

  • Pattern-51 prints decreasing alphabets while its row width decreases by two.
  • Pattern-52 uses alternate alphabets such as I, G, E, C, A.
  • The expression 2*num-2*i helps move backward through alternate alphabet positions.
  • Pattern-53 prints consecutive alphabets but decreases the number of alphabets by two in each row.
  • Pattern-54 is a number palindrome.
  • Pattern-55 is the alphabet equivalent of the palindrome pattern.
  • A palindrome pattern normally requires a forward loop and a reverse loop.
  • The center value should normally not be repeated when constructing a palindrome.
  • Pattern-56 always uses 0 as the center value.
  • Patterns 57 and 58 introduce two separate outer-loop sections.
  • The first outer loop generates the upper part.
  • The second outer loop generates the lower part.
  • Pattern-57 works with numbers while Pattern-58 applies similar logic to alphabets.
  • Pattern-59 combines increasing and decreasing star triangles.
  • Pattern-60 uses the same combined structure with reverse number sequences.
  • When solving complex patterns, first identify the number of rows, spaces, values per row, starting value, and direction of movement.

Part 6 — Pattern Logic Summary

Pattern Pattern Type Key Concept
51 Inverted Repeated Alphabet Decreasing alphabet + odd width
52 Inverted Alternate Alphabet Alphabet decreases by 2
53 Inverted Alphabet Sequence Consecutive alphabets
54 Number Palindrome Forward + reverse
55 Alphabet Palindrome ASCII forward + reverse
56 Zero-Centered Number Pyramid Decrease → 0 → increase
57 Combined Number Pattern Upper + lower sections
58 Combined Alphabet Pattern Upper + lower alphabet sections
59 Combined Star Pattern Increase + decrease
60 Combined Reverse Number Pattern Reverse sequence + row symmetry

Part 6 — Quick Revision

                     PATTERN 51-60
                           │
          ┌────────────────┼────────────────┐
          │                │                │
          ▼                ▼                ▼
      Pattern 51-53    Pattern 54-56    Pattern 57-60
       INVERTED          SYMMETRIC        COMBINED
       ALPHABET           PYRAMID          PATTERNS
          │                │                │
     ┌────┼────┐      ┌────┼────┐      ┌────┼──────┐
     ▼    ▼    ▼      ▼    ▼    ▼      ▼    ▼      ▼
    51   52   53     54   55   56     57   58    59-60
     │    │    │      │    │    │      │    │      │
 Repeated Odd Sequence Num Alpha Zero  Num Alpha  Star/Num
 Alphabet Pos.         Pal. Pal. Center

Introduction

Part 7 covers Pattern-61 to Pattern-70.

In this part, we will learn:

Pattern-61 → Combined Increasing Number Sequence
Pattern-62 → Vertically Symmetrical Repeated Alphabets
Pattern-63 → Vertically Symmetrical Reverse Alphabet Sequence
Pattern-64 → Vertically Symmetrical Forward Alphabet Sequence
Pattern-65 → Right-Aligned Increasing Star Triangle
Pattern-66 → Right-Aligned Repeated Number Triangle
Pattern-67 → Right-Aligned Number Sequence Triangle
Pattern-68 → Right-Aligned Repeated Alphabet Triangle
Pattern-69 → Right-Aligned Alphabet Sequence Triangle
Pattern-70 → Right-Aligned Decreasing Star Triangle

Important concepts used in this part are:

  • Nested for loops
  • Two-part vertically symmetrical patterns
  • Increasing and decreasing row sizes
  • Right alignment using leading spaces
  • Repeated row values
  • Number sequences
  • ASCII values and chr()
  • Increasing triangles
  • Decreasing triangles

Pattern-61 — Combined Increasing Number Sequence

Pattern-61 creates a vertically symmetrical number pattern.

Output for num = 5

4
3 4
2 3 4
1 2 3 4
0 1 2 3 4
1 2 3 4
2 3 4
3 4
4

The pattern contains two sections:

Upper Part → Rows increase
Lower Part → Rows decrease

The last value of every visible row is:

4

Pattern-61 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-61 — Upper Part Explanation

The upper section is:

for i in range(1,num+1):
    for j in range(1,i+1):
        print(num-i+j-1,end=" ")
    print()

The main formula is:

num - i + j - 1

For num = 5:

i = 1 → 4
i = 2 → 3 4
i = 3 → 2 3 4
i = 4 → 1 2 3 4
i = 5 → 0 1 2 3 4

Each new row begins with a smaller number, but every row ends at 4.

Pattern-61 — Lower Part Explanation

The lower section is:

for a in range(1,num+1):
    for k in range(0,num-a):
        print(k+a,end=" ")
    print()

Its visible rows are:

1 2 3 4
2 3 4
3 4
4

The starting number increases while the number of values decreases.

Pattern-61 — Pattern Construction

Upper Part:

4
3 4
2 3 4
1 2 3 4
0 1 2 3 4

Lower Part:

1 2 3 4
2 3 4
3 4
4

Combined:

4
3 4
2 3 4
1 2 3 4
0 1 2 3 4
1 2 3 4
2 3 4
3 4
4

Pattern-62 — Vertically Symmetrical Repeated Alphabets

Pattern-62 creates vertical symmetry using repeated alphabets.

Output for num = 5

E
D D
C C C
B B B B
A A A A A
B B B B
C C C
D D
E

The alphabet changes like this:

E
D
C
B
A
B
C
D
E

The middle row contains the maximum number of values.

Pattern-62 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-62 — Upper Part

The alphabet is calculated using:

chr(65 + num - i)

For num = 5:

i = 1 → chr(69) → E
i = 2 → chr(68) → D
i = 3 → chr(67) → C
i = 4 → chr(66) → B
i = 5 → chr(65) → A

The number of repetitions equals the current row number.

E
D D
C C C
B B B B
A A A A A

Pattern-62 — Lower Part

The lower section uses:

chr(65 + a)

The alphabet now moves forward:

B → C → D → E

At the same time, the number of repetitions decreases:

4 → 3 → 2 → 1

Therefore:

B B B B
C C C
D D
E

Pattern-63 — Vertically Symmetrical Reverse Alphabet Sequence

Pattern-63 uses decreasing alphabet sequences in a vertically symmetrical structure.

Output for num = 5

E
E D
E D C
E D C B
E D C B A
E D C B
E D C
E D
E

Every row starts with:

E

The sequence moves backward through the alphabet.

Pattern-63 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-63 — Upper Part

The upper section uses:

chr(65 + num - j)

For num = 5:

j = 1 → E
j = 2 → D
j = 3 → C
j = 4 → B
j = 5 → A

Since the inner loop executes only i times:

E
E D
E D C
E D C B
E D C B A

Pattern-63 — Lower Part

The lower half reduces the sequence one value at a time.

E D C B
E D C
E D
E

The maximum row:

E D C B A

is printed only once.

Pattern-64 — Vertically Symmetrical Forward Alphabet Sequence

Pattern-64 is another vertically symmetrical alphabet pattern.

Output for num = 5

E
D E
C D E
B C D E
A B C D E
B C D E
C D E
D E
E

Unlike Pattern-63, the alphabets inside every row move in forward order.

Pattern-64 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-64 — Upper Part Formula

The main expression is:

chr(64 + num - i + j)

For num = 5:

i = 1 → E
i = 2 → D E
i = 3 → C D E
i = 4 → B C D E
i = 5 → A B C D E

The starting alphabet moves backward:

E → D → C → B → A

but each individual row moves forward.

Pattern-64 — Lower Part

The second half produces:

B C D E
C D E
D E
E

Its starting alphabet moves forward while its row size decreases.

Therefore, the complete pattern is vertically symmetrical.

Pattern-62 vs Pattern-63 vs Pattern-64

Pattern Row Content Example Middle Row
62 Repeated alphabet A A A A A
63 Reverse alphabet sequence E D C B A
64 Forward alphabet sequence A B C D E

Pattern-65 — Right-Aligned Increasing Star Triangle

Pattern-65 begins a new family of right-aligned triangle patterns.

Output for num = 5

    *
   * *
  * * *
 * * * *
* * * * *

Two things happen in every row:

Leading Spaces → Decrease
Stars          → Increase

Pattern-65 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-65 — Step-by-Step Logic

Leading Spaces

" " * (num-i)

For num = 5:

i = 1 → 4 spaces
i = 2 → 3 spaces
i = 3 → 2 spaces
i = 4 → 1 space
i = 5 → 0 spaces

Stars

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

The star count is equal to i.

1 → *
2 → * *
3 → * * *
4 → * * * *
5 → * * * * *

Pattern-65 — Dry Run

i Leading Spaces Stars
141
232
323
414
505

Pattern-66 — Right-Aligned Repeated Number Triangle

Pattern-66 replaces the stars of Pattern-65 with the current row number.

Output for num = 5

    1
   2 2
  3 3 3
 4 4 4 4
5 5 5 5 5

The row number determines both:

Value       → i
Repetitions → i

Pattern-66 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-66 — Logic

The spaces are exactly the same as Pattern-65:

num - i

The inner loop executes i times:

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

But instead of printing *, it prints:

i

For example, when i = 4:

4 4 4 4

Pattern-67 — Right-Aligned Number Sequence Triangle

Pattern-67 prints increasing number sequences in a right-aligned triangle.

Output for num = 5

    1
   1 2
  1 2 3
 1 2 3 4
1 2 3 4 5

Every row starts from 1.

Pattern-67 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-67 — Inner Loop

for j in range(1,i+1):
    print(j,end=" ")

The value of j is printed directly.

Therefore:

i = 1 → 1
i = 2 → 1 2
i = 3 → 1 2 3
i = 4 → 1 2 3 4
i = 5 → 1 2 3 4 5

Pattern-65 vs Pattern-66 vs Pattern-67

Pattern Printed Value Example Row 4
65 * * * * *
66 i 4 4 4 4
67 j 1 2 3 4

The triangle structure is identical. Only the printed value changes.

Pattern-68 — Right-Aligned Repeated Alphabet Triangle

Pattern-68 is the alphabet version of Pattern-66.

Output for num = 5

    A
   B B
  C C C
 D D D D
E E E E E

Each row prints one alphabet repeatedly.

Pattern-68 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-68 — Alphabet Formula

The expression is:

chr(64 + i)

Therefore:

i = 1 → chr(65) → A
i = 2 → chr(66) → B
i = 3 → chr(67) → C
i = 4 → chr(68) → D
i = 5 → chr(69) → E

The inner loop repeats the selected alphabet i times.

A
B B
C C C
D D D D
E E E E E

Pattern-69 — Right-Aligned Alphabet Sequence Triangle

Pattern-69 is the alphabet version of Pattern-67.

Output for num = 5

    A
   A B
  A B C
 A B C D
A B C D E

Every row starts from A and moves forward through the alphabet.

Pattern-69 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-69 — Alphabet Sequence Logic

The alphabet depends on the column variable:

chr(64 + j)

Therefore:

j = 1 → A
j = 2 → B
j = 3 → C
j = 4 → D
j = 5 → E

Because the inner loop ends at i:

Row 1 → A
Row 2 → A B
Row 3 → A B C
Row 4 → A B C D
Row 5 → A B C D E

Pattern-66 vs Pattern-68

Feature Pattern-66 Pattern-68
Type Numbers Alphabets
Value i chr(64+i)
Repeated Value Yes Yes
Alignment Right Right

Pattern-67 vs Pattern-69

Feature Pattern-67 Pattern-69
Sequence 1, 2, 3... A, B, C...
Printed Expression j chr(64+j)
Starts Each Row From 1 A
Row Size Increasing Increasing

Pattern-70 — Right-Aligned Decreasing Star Triangle

Pattern-70 begins the right-aligned decreasing triangle family.

Output for num = 5

* * * * *
 * * * *
  * * *
   * *
    *

Unlike Pattern-65:

Spaces → Increase
Stars  → Decrease

Pattern-70 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-70 — Leading Spaces

The expression:

" " * (i-1)

controls the indentation.

For num = 5:

i = 1 → 0 spaces
i = 2 → 1 space
i = 3 → 2 spaces
i = 4 → 3 spaces
i = 5 → 4 spaces

The spaces increase from top to bottom.

Pattern-70 — Star Count

The inner loop is:

for j in range(1,num+2-i):

The number of iterations is:

num + 1 - i

For num = 5:

i = 1 → 5 stars
i = 2 → 4 stars
i = 3 → 3 stars
i = 4 → 2 stars
i = 5 → 1 star

Pattern-70 — Dry Run

i Spaces Stars
105
214
323
432
541

Pattern-65 vs Pattern-70

Feature Pattern-65 Pattern-70
Triangle Increasing Decreasing
Spaces Decrease Increase
Stars Increase Decrease
Space Formula num-i i-1
Star Count i num+1-i

Pattern-61 to Pattern-64 — Vertical Symmetry Family

Pattern Data Middle Row Main Idea
61 Numbers 0 1 2 3 4 Increasing sequence
62 Alphabets A A A A A Repeated alphabet
63 Alphabets E D C B A Reverse sequence
64 Alphabets A B C D E Forward sequence

Pattern-65 to Pattern-69 — Right-Aligned Increasing Family

Patterns 65–69 use almost the same triangle structure.

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

    print(" "*(num-i),end="")

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

        # Print required value

    print()

Only the value printed inside the inner loop changes.

Pattern Printed Expression
65 "*"
66 i
67 j
68 chr(64+i)
69 chr(64+j)

Understanding i and j in Pattern Programs

Patterns 65–69 clearly demonstrate the difference between printing i and printing j.

Printing i

for i in range(1,num+1):
    for j in range(1,i+1):
        print(i,end=" ")

The same value repeats across the row:

1
2 2
3 3 3

Printing j

for i in range(1,num+1):
    for j in range(1,i+1):
        print(j,end=" ")

The value changes across the row:

1
1 2
1 2 3

The same idea applies to alphabets:

chr(64+i) → Repeated alphabet
chr(64+j) → Alphabet sequence

Right Alignment Formula

For an increasing right-aligned triangle:

Spaces = num - i
Values = i

Therefore:

Row 1 → Maximum spaces + Minimum values
Row 2 → Fewer spaces   + More values
...
Last  → Zero spaces    + Maximum values

For a decreasing right-aligned triangle:

Spaces = i - 1
Values = num + 1 - i

Therefore:

Row 1 → Zero spaces    + Maximum values
Row 2 → More spaces    + Fewer values
...
Last  → Maximum spaces + One value

Important Formulas in Part 7

Pattern-61

num - i + j - 1

Pattern-62 Upper Alphabet

chr(65 + num - i)

Pattern-62 Lower Alphabet

chr(65 + a)

Pattern-63 Reverse Alphabet

chr(65 + num - j)

Pattern-64 Forward Alphabet

chr(64 + num - i + j)

Increasing Right Alignment

" " * (num-i)

Repeated Row Number

i

Increasing Number Sequence

j

Repeated Row Alphabet

chr(64+i)

Increasing Alphabet Sequence

chr(64+j)

Decreasing Right Alignment

" " * (i-1)

Decreasing Row Size

num + 1 - i

How to Identify the Correct Variable

Before writing the inner print(), ask what changes in the pattern.

Case 1 — Same value throughout the row

1
2 2
3 3 3

Use the row variable:

print(i,end=" ")

Case 2 — Values change across the row

1
1 2
1 2 3

Use the column variable:

print(j,end=" ")

Case 3 — Same alphabet throughout the row

A
B B
C C C

Use:

chr(64+i)

Case 4 — Alphabet changes across the row

A
A B
A B C

Use:

chr(64+j)

Part 7 — Execution Flow

                         START
                           │
                           ▼
                       Read num
                           │
                           ▼
                 Identify Pattern Type
                           │
          ┌────────────────┼──────────────────┐
          │                │                  │
          ▼                ▼                  ▼
      Combined         Right-Aligned      Right-Aligned
      Symmetry          Increasing         Decreasing
       61-64             65-69                70
          │                │                  │
          ▼                ▼                  ▼
    Print Upper       Spaces Decrease     Spaces Increase
          │                │                  │
          ▼                ▼                  ▼
    Middle Row        Values Increase     Values Decrease
          │                │                  │
          ▼                ▼                  ▼
    Print Lower       Print *, Number     Print *
          │           or Alphabet             │
          │                │                  │
          └────────────────┼──────────────────┘
                           │
                           ▼
                         Next Row
                           │
                           ▼
                          END

Part 7 — Important Notes

  • Pattern-61 is the number-sequence counterpart of the combined symmetrical patterns from the previous part.
  • Patterns 62–64 are vertically symmetrical alphabet patterns.
  • Pattern-62 repeats the same alphabet in each row.
  • Pattern-63 prints alphabets in reverse order inside each row.
  • Pattern-64 prints alphabets in forward order inside each row.
  • Patterns 61–64 use separate loops for the upper and lower sections.
  • Patterns 65–69 share almost exactly the same triangle structure.
  • For right-aligned increasing triangles, leading spaces are calculated using num-i.
  • Pattern-65 prints stars.
  • Pattern-66 prints the row variable i.
  • Pattern-67 prints the column variable j.
  • Pattern-68 converts i into an alphabet using chr(64+i).
  • Pattern-69 converts j into an alphabet using chr(64+j).
  • Pattern-70 reverses the right-aligned triangle logic.
  • In Pattern-70, spaces increase while stars decrease.
  • Understanding whether the output depends on the row or column is one of the most important concepts in pattern programming.

Part 7 — Pattern Logic Summary

Pattern Pattern Type Key Concept
61 Combined Number Sequence Vertical number symmetry
62 Repeated Alphabet Symmetry Repeated letters + vertical symmetry
63 Reverse Alphabet Symmetry Reverse alphabet sequence
64 Forward Alphabet Symmetry Forward alphabet sequence
65 Increasing Star Triangle Right alignment
66 Repeated Number Triangle Print i
67 Number Sequence Triangle Print j
68 Repeated Alphabet Triangle chr(64+i)
69 Alphabet Sequence Triangle chr(64+j)
70 Decreasing Star Triangle Increasing spaces + decreasing stars

Part 7 — Quick Revision

                       PATTERN 61-70
                             │
          ┌──────────────────┼──────────────────┐
          │                  │                  │
          ▼                  ▼                  ▼
       61 - 64            65 - 69              70
       VERTICAL          RIGHT-ALIGNED      RIGHT-ALIGNED
       SYMMETRY           INCREASING         DECREASING
          │                  │                  │
     ┌────┼────┐       ┌─────┼─────┐            │
     ▼    ▼    ▼       ▼     ▼     ▼            ▼
   Number Rep. Sequence Star Number Alphabet    Star
          │              │     │      │
          │              │   i / j  i / j
          │              │
          ▼              ▼
     Upper + Lower   Spaces = num-i

                       Pattern-70
                           │
                           ▼
                    Spaces = i-1
                           │
                           ▼
                 Values = num+1-i

Introduction

Part 8 covers Pattern-71 to Pattern-80.

In this part, we will learn:

Pattern-71 → Right-Aligned Decreasing Repeated Numbers
Pattern-72 → Right-Aligned Decreasing Number Sequence
Pattern-73 → Right-Aligned Decreasing Repeated Alphabets
Pattern-74 → Right-Aligned Decreasing Reverse Alphabet Sequence
Pattern-75 → Right-Aligned Decreasing Forward Alphabet Sequence
Pattern-76 → Combined Star Diamond Pattern
Pattern-77 → Combined Repeated Number Diamond
Pattern-78 → Combined Number Sequence Pattern
Pattern-79 → Symmetrical Number Sequence Diamond
Pattern-80 → Combined Repeated Alphabet Diamond

The important concepts used are:

  • Nested for loops
  • Increasing leading spaces
  • Decreasing row sizes
  • Repeated numbers
  • Descending number sequences
  • ASCII values and chr()
  • Forward and reverse alphabet sequences
  • Upper and lower pattern sections
  • Diamond-like patterns
  • Vertical symmetry

Pattern-71 — Right-Aligned Decreasing Repeated Numbers

Pattern-71 is the number version of the decreasing star triangle from Pattern-70.

Output for num = 5

5 5 5 5 5
 4 4 4 4
  3 3 3
   2 2
    1

Two changes happen from one row to the next:

Leading Spaces → Increase
Numbers        → Decrease

The same number is repeated throughout each row.

Pattern-71 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-71 — Step-by-Step Explanation

Step 1 — Read Number

num=int(input("Enter a number:"))

The value of num decides the number of rows.

Step 2 — Outer Loop

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

For num = 5, i takes:

1, 2, 3, 4, 5

Step 3 — Print Leading Spaces

print(" "*(i-1),end="")

Therefore:

i = 1 → 0 spaces
i = 2 → 1 space
i = 3 → 2 spaces
i = 4 → 3 spaces
i = 5 → 4 spaces

Step 4 — Print Numbers

print(num-i+1,end=" ")

The printed value decreases:

5 → 4 → 3 → 2 → 1

The number of repetitions also decreases.

Pattern-71 — Dry Run

i Spaces Printed Value Repetitions
1055
2144
3233
4322
5411

Pattern-72 — Right-Aligned Decreasing Number Sequence

Pattern-72 prints descending number sequences.

Output for num = 5

5 4 3 2 1
 4 3 2 1
  3 2 1
   2 1
    1

The first value decreases on every row:

5 → 4 → 3 → 2 → 1

Every row ends with 1.

Pattern-72 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-72 — Number Formula

The important expression is:

num + 2 - i - j

For num = 5 and i = 1:

j = 1 → 5 + 2 - 1 - 1 = 5
j = 2 → 5 + 2 - 1 - 2 = 4
j = 3 → 3
j = 4 → 2
j = 5 → 1

Therefore, the first row becomes:

5 4 3 2 1

For i = 3:

3 2 1

Pattern-71 vs Pattern-72

Feature Pattern-71 Pattern-72
Values in Row Repeated Changing
First Row 5 5 5 5 5 5 4 3 2 1
Printed Expression num-i+1 num+2-i-j
Alignment Right Right

Pattern-73 — Right-Aligned Decreasing Repeated Alphabets

Pattern-73 is the alphabet version of Pattern-71.

Output for num = 5

E E E E E
 D D D D
  C C C
   B B
    A

The alphabet changes from:

E → D → C → B → A

The selected alphabet is repeated throughout its row.

Pattern-73 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-73 — Alphabet Formula

The alphabet is calculated using:

chr(65 + num - i)

For num = 5:

i = 1 → chr(69) → E
i = 2 → chr(68) → D
i = 3 → chr(67) → C
i = 4 → chr(66) → B
i = 5 → chr(65) → A

The number of repetitions is:

num + 1 - i

Therefore:

E → 5 times
D → 4 times
C → 3 times
B → 2 times
A → 1 time

Pattern-74 — Right-Aligned Decreasing Reverse Alphabet Sequence

Pattern-74 prints alphabets in reverse order inside each row.

Output for num = 5

E D C B A
 D C B A
  C B A
   B A
    A

The starting alphabet changes:

E → D → C → B → A

Every row finally reaches A.

Pattern-74 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-74 — Inner Loop Explanation

The inner loop is:

for j in range(num+1-i,0,-1):

For num = 5:

i = 1 → j = 5,4,3,2,1
i = 2 → j = 4,3,2,1
i = 3 → j = 3,2,1
i = 4 → j = 2,1
i = 5 → j = 1

The expression:

chr(64+j)

converts these numbers into:

1 → A
2 → B
3 → C
4 → D
5 → E

Since j decreases, the alphabet sequence is also reversed.

Pattern-75 — Right-Aligned Decreasing Forward Alphabet Sequence

Pattern-75 prints a forward alphabet sequence while the row size decreases.

Output for num = 5

A B C D E
 A B C D
  A B C
   A B
    A

Every row begins with:

A

The ending alphabet changes:

E → D → C → B → A

Pattern-75 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-75 — Step-by-Step Explanation

The leading spaces are:

i - 1

The inner loop executes:

num + 1 - i

times.

The alphabet is generated using:

chr(64+j)

Therefore:

Row 1 → A B C D E
Row 2 → A B C D
Row 3 → A B C
Row 4 → A B
Row 5 → A

Pattern-73 vs Pattern-74 vs Pattern-75

Pattern Type First Row
73 Repeated Alphabet E E E E E
74 Reverse Alphabet Sequence E D C B A
75 Forward Alphabet Sequence A B C D E

Pattern-76 — Combined Star Diamond Pattern

Pattern-76 combines an increasing star triangle and a decreasing star triangle.

Output for num = 5

    *
   * *
  * * *
 * * * *
* * * * *
 * * * *
  * * *
   * *
    *

The pattern contains two sections:

Upper Part → Increasing Star Triangle
Lower Part → Decreasing Star Triangle

The middle row contains the maximum number of stars and is printed only once.

Pattern-76 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-76 — Upper Part Explanation

The upper part is:

for i in range(1,num+1):
    print(" "*(num-i),end="")
    for j in range(1,i+1):
        print("*",end=" ")
    print()

Here:

Spaces → num-i
Stars  → i

For num = 5:

4 spaces + 1 star
3 spaces + 2 stars
2 spaces + 3 stars
1 space  + 4 stars
0 spaces + 5 stars

Pattern-76 — Lower Part Explanation

The lower part is:

for p in range(1,num):
    print(" "*p,end="")
    for q in range(1,num+1-p):
        print("*",end=" ")
    print()

Here:

Spaces → p
Stars  → num-p

Therefore:

1 space  + 4 stars
2 spaces + 3 stars
3 spaces + 2 stars
4 spaces + 1 star

The lower loop uses:

range(1,num)

instead of:

range(1,num+1)

This prevents the middle row from being printed twice.

Pattern-77 — Combined Repeated Number Diamond

Pattern-77 replaces the stars of Pattern-76 with repeated row numbers.

Output for num = 5

    1
   2 2
  3 3 3
 4 4 4 4
5 5 5 5 5
 4 4 4 4
  3 3 3
   2 2
    1

The values increase toward the middle:

1 → 2 → 3 → 4 → 5

and then decrease:

4 → 3 → 2 → 1

Pattern-77 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-77 — Upper and Lower Logic

Upper Part

print(i,end=" ")

This produces:

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Lower Part

print(num-p,end=" ")

For num = 5:

p = 1 → 4
p = 2 → 3
p = 3 → 2
p = 4 → 1

Therefore:

4 4 4 4
3 3 3
2 2
1

Pattern-78 — Combined Number Sequence Pattern

Pattern-78 uses increasing number sequences in the upper part and shifted number sequences in the lower part.

Output for num = 5

    1
   1 2
  1 2 3
 1 2 3 4
1 2 3 4 5
 2 3 4 5
  3 4 5
   4 5
    5

The upper part always starts from 1.

The lower part starts from progressively larger numbers:

2
3
4
5

Pattern-78 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-78 — Upper Part

The upper part prints:

j

Therefore:

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Pattern-78 — Lower Part

The lower section uses:

q + p

For the first lower row:

p = 1

q = 1 → 2
q = 2 → 3
q = 3 → 4
q = 4 → 5

Result:

2 3 4 5

For the next row:

p = 2

3 4 5

Therefore, the lower section becomes:

2 3 4 5
3 4 5
4 5
5

Pattern-79 — Symmetrical Number Sequence Diamond

Pattern-79 is similar to Pattern-78, but every row starts from 1.

Output for num = 5

    1
   1 2
  1 2 3
 1 2 3 4
1 2 3 4 5
 1 2 3 4
  1 2 3
   1 2
    1

The upper and lower sections are vertically symmetrical.

Pattern-79 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-79 — Step-by-Step Explanation

Upper Section

print(j,end=" ")

creates:

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Lower Section

The lower section also prints:

q

However, the inner-loop size decreases:

num-p

Therefore:

1 2 3 4
1 2 3
1 2
1

Pattern-78 vs Pattern-79

Feature Pattern-78 Pattern-79
Upper Part 1-based sequence 1-based sequence
Lower Expression q+p q
Lower First Row 2 3 4 5 1 2 3 4
Vertically Symmetrical Values No Yes

Pattern-80 — Combined Repeated Alphabet Diamond

Pattern-80 is the alphabet version of Pattern-77.

Output for num = 5

    A
   B B
  C C C
 D D D D
E E E E E
 D D D D
  C C C
   B B
    A

The alphabet moves forward toward the middle:

A → B → C → D → E

and then backward:

D → C → B → A

Pattern-80 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-80 — Upper Part Explanation

The upper alphabet is calculated using:

chr(64+i)

Therefore:

i = 1 → A
i = 2 → B
i = 3 → C
i = 4 → D
i = 5 → E

Each alphabet repeats i times:

A
B B
C C C
D D D D
E E E E E

Pattern-80 — Lower Part Explanation

The lower alphabet is calculated using:

chr(64 + num - p)

For num = 5:

p = 1 → chr(68) → D
p = 2 → chr(67) → C
p = 3 → chr(66) → B
p = 4 → chr(65) → A

The repetitions also decrease:

D D D D
C C C
B B
A

Pattern-70 to Pattern-75 — Decreasing Triangle Family

Patterns 70–75 use the same basic decreasing right-aligned structure.

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

    print(" "*(i-1),end="")

    # Print decreasing number of values

    print()
Pattern Output Type Main Expression
70 Stars "*"
71 Repeated Numbers num-i+1
72 Descending Numbers num+2-i-j
73 Repeated Alphabets chr(65+num-i)
74 Reverse Alphabet Sequence chr(64+j) with decreasing j
75 Forward Alphabet Sequence chr(64+j)

Pattern-76 to Pattern-80 — Combined Pattern Family

Patterns 76–80 combine two triangles.

General Structure

Upper Increasing Part
        │
        ▼
Maximum Middle Row
        │
        ▼
Lower Decreasing Part

The upper section normally uses:

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

The lower section uses:

for p in range(1,num):

The lower section stops at num-1 because the maximum middle row has already been printed by the upper section.

Pattern-76 to Pattern-80 — Comparison

Pattern Data Upper Logic Lower Logic
76 Stars Increasing stars Decreasing stars
77 Repeated Numbers i num-p
78 Number Sequence j q+p
79 Number Sequence j q
80 Repeated Alphabets chr(64+i) chr(64+num-p)

Understanding the Two Sets of Loop Variables

Combined patterns use two separate sets of loop variables.

Upper Part

i → Row
j → Column

Lower Part

p → Row
q → Column

For example:

for i in range(1,num+1):
    ...
    for j in range(...):
        ...

for p in range(1,num):
    ...
    for q in range(...):
        ...

Using different variable names makes it easier to understand which loops belong to the upper and lower sections.

Why range(1,num) is Used in the Lower Part

This is an important concept in Patterns 76–80.

Suppose:

num = 5

The upper section already produces:

Row 1
Row 2
Row 3
Row 4
Row 5 ← Maximum/Middle Row

The lower section should therefore produce only:

Row 4
Row 3
Row 2
Row 1

So it needs only:

num - 1

iterations.

Hence:

for p in range(1,num):

If we incorrectly used:

range(1,num+1)

an unnecessary extra row would be processed.

Important Formulas in Part 8

Increasing Leading Spaces

" " * (i-1)

Decreasing Row Size

num + 1 - i

Repeated Decreasing Number

num - i + 1

Descending Number Sequence

num + 2 - i - j

Repeated Decreasing Alphabet

chr(65 + num - i)

Reverse Alphabet

chr(64+j)

with j running backward.

Forward Alphabet

chr(64+j)

with j running forward.

Upper Diamond Spaces

num - i

Lower Diamond Spaces

p

Pattern-77 Lower Value

num - p

Pattern-78 Lower Value

q + p

Pattern-79 Lower Value

q

Pattern-80 Upper Alphabet

chr(64+i)

Pattern-80 Lower Alphabet

chr(64+num-p)

Part 8 — Execution Flow

                         START
                           │
                           ▼
                       Read num
                           │
                           ▼
                   Identify Pattern
                           │
             ┌─────────────┴─────────────┐
             │                           │
             ▼                           ▼
        Pattern 71-75               Pattern 76-80
        Decreasing                  Combined Pattern
        Triangle                         │
             │                           ▼
             ▼                     Print Upper Part
       Increase Spaces                    │
             │                           ▼
             ▼                     Print Middle Row
       Decrease Values                    │
             │                           ▼
             ▼                     Print Lower Part
     Print Number/Alphabet                 │
             │                           │
             └─────────────┬─────────────┘
                           │
                           ▼
                          END

Part 8 — Important Notes

  • Patterns 71–75 continue the decreasing right-aligned triangle family started by Pattern-70.
  • Leading spaces in Patterns 71–75 are controlled using i-1.
  • The number of printed values decreases as the row number increases.
  • Pattern-71 repeats the same decreasing number in each row.
  • Pattern-72 prints a descending sequence ending at 1.
  • Pattern-73 repeats the same alphabet in each row.
  • Pattern-74 prints alphabets in reverse order.
  • Pattern-75 prints alphabets in forward order.
  • Patterns 76–80 contain separate upper and lower sections.
  • Pattern-76 creates a star diamond-like structure.
  • Pattern-77 creates the same basic structure using repeated numbers.
  • Pattern-78 changes the starting value of each lower row.
  • Pattern-79 keeps every sequence starting from 1.
  • Pattern-80 converts the repeated-number diamond concept into alphabets.
  • The upper section normally uses variables i and j.
  • The lower section normally uses variables p and q.
  • The lower section uses range(1,num) so that the maximum middle row is not repeated.
  • chr() is used to convert ASCII values into alphabet characters.

Part 8 — Pattern Logic Summary

Pattern Pattern Type Main Concept
71 Repeated Number Decreasing Triangle num-i+1
72 Descending Number Triangle num+2-i-j
73 Repeated Alphabet Decreasing Triangle chr(65+num-i)
74 Reverse Alphabet Triangle Decreasing j
75 Forward Alphabet Triangle Increasing j
76 Star Diamond Increasing + decreasing stars
77 Repeated Number Diamond Increasing + decreasing row values
78 Shifted Number Diamond j and q+p
79 Symmetrical Number Diamond j and q
80 Repeated Alphabet Diamond Increasing + decreasing alphabets

Part 8 — Quick Revision

                    PATTERN 71-80
                          │
             ┌────────────┴────────────┐
             │                         │
             ▼                         ▼
         71 - 75                   76 - 80
       RIGHT-ALIGNED                COMBINED
        DECREASING                  PATTERNS
             │                         │
       ┌─────┼─────┐             ┌─────┼─────┐
       ▼     ▼     ▼             ▼     ▼     ▼
     Stars Numbers Alphabets    Stars Numbers Alphabets
      (70)  71-72    73-75       76   77-79     80
             │                         │
             ▼                         ▼
      Spaces Increase             Upper Triangle
      Values Decrease                  +
                                   Lower Triangle
                                       │
                                       ▼
                                  Diamond-Like
                                    Pattern

Introduction

Part 9 covers Pattern-81 to Pattern-90.

In this part, we will learn:

Pattern-81 → Combined Forward Alphabet Sequence
Pattern-82 → Symmetrical Increasing Number Diamond
Pattern-83 → Symmetrical Decreasing Number Diamond
Pattern-84 → Hollow Increasing Star Pattern
Pattern-85 → Hollow Increasing Number Pattern
Pattern-86 → Hollow Decreasing Number Pattern
Pattern-87 → Hollow Decreasing Alphabet Pattern
Pattern-88 → Hollow Increasing Alphabet Pattern
Pattern-89 → Hollow Decreasing Star Pattern
Pattern-90 → Hollow Increasing Number Inverted Pattern

The important concepts used in these patterns are:

  • Nested loops
  • Upper and lower pattern sections
  • Increasing and decreasing spaces
  • Forward and reverse number sequences
  • Forward and reverse alphabet sequences
  • ASCII values with chr()
  • Symmetrical patterns
  • Hollow patterns
  • Left and right boundaries
  • Dynamic inner spaces

Pattern-81 — Combined Forward Alphabet Sequence

Pattern-81 continues the combined alphabet patterns.

The upper part starts every row from A. The lower part changes the starting alphabet on every row.

Output for num = 5

    A
   A B
  A B C
 A B C D
A B C D E
 B C D E
  C D E
   D E
    E

Observe the upper section:

A
A B
A B C
A B C D
A B C D E

The lower section becomes:

B C D E
C D E
D E
E

Pattern-81 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-81 — Upper Part Explanation

The upper section is:

for i in range(1,num+1):
    print(" "*(num-i),end="")
    for j in range(1,i+1):
        print(chr(64+j),end=" ")
    print()

The number of leading spaces is:

num - i

The alphabet is generated using:

chr(64+j)

Therefore:

j = 1 → A
j = 2 → B
j = 3 → C
j = 4 → D
j = 5 → E

As i increases, more alphabets are printed.

Pattern-81 — Lower Part Explanation

The lower section uses:

chr(64+q+p)

Here p shifts the starting alphabet.

When p = 1

q = 1 → chr(66) → B
q = 2 → chr(67) → C
q = 3 → chr(68) → D
q = 4 → chr(69) → E

Output:

B C D E

When p = 2

C D E

When p = 3

D E

When p = 4

E

Pattern-81 — Execution Flow

Read num
   │
   ▼
Print Upper Section
   │
   ├── Decrease leading spaces
   │
   └── Print A to current alphabet
   │
   ▼
Print Lower Section
   │
   ├── Increase leading spaces
   │
   └── Shift starting alphabet
   │
   ▼
End

Pattern-82 — Symmetrical Increasing Number Diamond

Pattern-82 creates a vertically symmetrical number pattern.

Each row first increases toward 5 and then decreases.

Output for n = 5

    5
   4 5 4
  3 4 5 4 3
 2 3 4 5 4 3 2
1 2 3 4 5 4 3 2 1
 2 3 4 5 4 3 2
  3 4 5 4 3
   4 5 4
    5

The centre value is:

5

Numbers move toward the centre and then reverse.

Pattern-82 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-82 — Upper Section Explanation

The first inner loop is:

for j in range(1,i+1):
    print(n-i+j,end=" ")

This generates the increasing half.

For n = 5 and i = 4:

n-i+j

j = 1 → 2
j = 2 → 3
j = 3 → 4
j = 4 → 5

So the first half becomes:

2 3 4 5

The second loop is:

for k in range(2,i+1):
    print(n+1-k,end=" ")

It produces:

4 3 2

The complete row becomes:

2 3 4 5 4 3 2

Pattern-82 — Why k Starts from 2

The value 5 has already been printed by the first loop.

If the second loop started from 1, the middle value would appear twice.

Therefore:

range(2,i+1)

is used.

Pattern-82 — Row Analysis

Row Starting Number Middle Number Ending Number
1555
2454
3353
4252
5151

Pattern-83 — Symmetrical Decreasing Number Diamond

Pattern-83 creates another complex symmetrical number pattern.

Unlike Pattern-82, the upper rows begin from 5 and decrease toward the centre before increasing again.

Output for n = 5

    5
   5 4 5
  5 4 3 4 5
 5 4 3 2 3 4 5
5 4 3 2 1 2 3 4 5
 5 4 3 2 3 4 5
  5 4 3 4 5
   5 4 5
    5

Pattern-83 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-83 — Important Note About while True

The program in the document starts with:

while True:

Therefore, after printing one complete pattern, the program again asks:

Enter a number:

This creates an infinite repetition until the program is manually stopped.

Pattern-83 — Upper Section Explanation

The first half of each upper row is generated using:

n + 1 - j

For n = 5 and i = 4:

j = 1 → 5
j = 2 → 4
j = 3 → 3
j = 4 → 2

First half:

5 4 3 2

The second half uses:

n - i + k

For i = 4:

k = 2 → 3
k = 3 → 4
k = 4 → 5

Therefore the complete row is:

5 4 3 2 3 4 5

Pattern-82 vs Pattern-83

Feature Pattern-82 Pattern-83
Outer Edge Changes 5 → 1 Main rows start with 5
Movement to Centre Increasing Decreasing
Centre Value 5 Changes toward 1
Middle Row 1 2 3 4 5 4 3 2 1 5 4 3 2 1 2 3 4 5

Pattern-84 — Hollow Increasing Star Pattern

Pattern-84 begins the hollow or outline-style pattern family.

Instead of filling the complete triangle with stars, only two boundary stars are printed.

Output for num = 5

    *
   * *
  *   *
 *     *
*       *

The distance between the two stars increases on every row.

Pattern-84 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-84 — Step-by-Step Explanation

Leading Spaces

" " * (num-i)

The leading spaces decrease:

4 → 3 → 2 → 1 → 0

First Star

for j in range(i,i+1):
    print("*",end=" ")

The loop executes exactly once, so one left-side star is printed.

Inner Spaces

2*i - 4

For rows starting from row 2:

i = 2 → 0
i = 3 → 2
i = 4 → 4
i = 5 → 6

Second Star

The second boundary star is printed only when:

i >= 2

This is why the first row contains only one star.

Pattern-85 — Hollow Increasing Number Pattern

Pattern-85 uses the same structure as Pattern-84, but replaces stars with row numbers.

Output for num = 5

    1
   2 2
  3   3
 4     4
5       5

The number increases:

1 → 2 → 3 → 4 → 5

Pattern-85 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-85 — Program Explanation

The left and right boundaries print:

i

Therefore:

Row 1 → 1
Row 2 → 2
Row 3 → 3
Row 4 → 4
Row 5 → 5

Both sides contain the same number.

The inner-space formula remains:

2*i - 4

Therefore Pattern-85 is the number version of Pattern-84.

Pattern-86 — Hollow Decreasing Number Pattern

Pattern-86 reverses the values used in Pattern-85.

Output for num = 5

    5
   4 4
  3   3
 2     2
1       1

The values decrease:

5 → 4 → 3 → 2 → 1

Pattern-86 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-86 — Number Formula

The important expression is:

num + 1 - i

For num = 5:

i = 1 → 5
i = 2 → 4
i = 3 → 3
i = 4 → 2
i = 5 → 1

The same value is printed at both boundaries.

Pattern-85 vs Pattern-86

Feature Pattern-85 Pattern-86
Values Increasing Decreasing
Formula i num+1-i
First Value 1 5
Last Value 5 1

Pattern-87 — Hollow Decreasing Alphabet Pattern

Pattern-87 converts Pattern-86 into alphabets.

Output for num = 5

    E
   D D
  C   C
 B     B
A       A

The alphabet sequence is:

E → D → C → B → A

Pattern-87 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-87 — Alphabet Formula

The expression is:

chr(64 + num + 1 - i)

For num = 5:

i = 1 → chr(69) → E
i = 2 → chr(68) → D
i = 3 → chr(67) → C
i = 4 → chr(66) → B
i = 5 → chr(65) → A

Both boundaries use the same alphabet.

Pattern-88 — Hollow Increasing Alphabet Pattern

Pattern-88 prints alphabets in increasing order.

Output for num = 5

    A
   B B
  C   C
 D     D
E       E

The alphabet sequence is:

A → B → C → D → E

Pattern-88 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-88 — Alphabet Formula

The expression is:

chr(64+i)

Therefore:

i = 1 → A
i = 2 → B
i = 3 → C
i = 4 → D
i = 5 → E

The first row contains one alphabet.

From the second row onward, the same alphabet appears on both boundaries.

Pattern-87 vs Pattern-88

Feature Pattern-87 Pattern-88
Alphabet Direction E → A A → E
Formula chr(64+num+1-i) chr(64+i)
Shape Hollow Increasing Triangle Hollow Increasing Triangle

Pattern-89 — Hollow Decreasing Star Pattern

Pattern-89 reverses the direction of Pattern-84.

The pattern starts wide and gradually closes toward the bottom.

Output for num = 5

*       *
 *     *
  *   *
   * *
    *

The leading spaces increase while the inner spaces decrease.

Pattern-89 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-89 — Step-by-Step Explanation

Leading Spaces

i - 1

They increase:

0 → 1 → 2 → 3 → 4

Inner Spaces

2*num - 2*i - 2

For num = 5:

i = 1 → 6 spaces
i = 2 → 4 spaces
i = 3 → 2 spaces
i = 4 → 0 spaces

On the last row, only one star is required.

The document uses:

if i <= 4:

For num = 5, this prevents a second star from being printed on the final row.

Pattern-90 — Hollow Increasing Number Inverted Pattern

Pattern-90 uses the same decreasing hollow structure as Pattern-89, but prints increasing row numbers.

Output for num = 5

1       1
 2     2
  3   3
   4 4
    5

The row values increase:

1 → 2 → 3 → 4 → 5

At the same time, the two boundaries move toward each other.

Pattern-90 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-90 — Program Explanation

Step 1 — Read Number

num=int(input("Enter a number:"))

Step 2 — Control Rows

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

Step 3 — Print Leading Spaces

print(" "*(i-1),end="")

The pattern moves toward the right as i increases.

Step 4 — Print Left Number

print(i,end=" ")

Step 5 — Check Whether Another Boundary is Required

if i

For all rows except the last row, the program prints inner spaces and another copy of the row number.

Step 6 — Print Inner Spaces

2*num - 2*i - 2

Step 7 — Print Right Number

print(i,end=" ")

On the final row:

i == num

so the condition becomes false and only one number is printed.

Understanding Hollow Patterns

A hollow pattern does not print values at every position.

Instead, values are mainly printed at the boundaries.

Filled Pattern

    *
   * *
  * * *
 * * * *
* * * * *

Hollow Pattern

    *
   * *
  *   *
 *     *
*       *

The important difference is the space between the left and right boundaries.

Instead of printing several stars, numbers, or alphabets, the program prints:

Left Boundary
     +
Inner Spaces
     +
Right Boundary

Increasing Hollow Pattern Formula

Patterns 84–88 use the increasing hollow structure.

General Structure

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

    print(" "*(num-i),end="")

    print(left_boundary,end=" ")

    if i>=2:
        print(" "*(2*i-4),end="")
        print(right_boundary,end=" ")

    print()

Leading Spaces

num - i

These decrease.

Inner Spaces

2*i - 4

These increase.

Therefore, the two boundaries move away from each other.

Decreasing Hollow Pattern Formula

Patterns 89–90 reverse the hollow structure.

General Logic

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

    print(" "*(i-1),end="")

    print(left_boundary,end=" ")

    if i

Leading Spaces

i - 1

These increase.

Inner Spaces

2*num - 2*i - 2

These decrease.

Therefore, the left and right boundaries gradually move toward each other.

Why range(i, i+1) Executes Only Once

Several programs in this part contain:

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

This range contains only one value:

i

For example, if:

i = 3

then:

range(3,4)

contains only:

3

Therefore, the loop executes exactly once.

The same concept is used with:

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

It prints exactly one right-boundary value.

Pattern-84 to Pattern-88 — Comparison

Pattern Boundary Value Direction Formula
84 * Increasing Width "*"
85 Number 1 → 5 i
86 Number 5 → 1 num+1-i
87 Alphabet E → A chr(64+num+1-i)
88 Alphabet A → E chr(64+i)

Pattern-89 and Pattern-90 — Comparison

Feature Pattern-89 Pattern-90
Boundary Star Number
Shape Decreasing Hollow Decreasing Hollow
Leading Spaces i-1 i-1
Inner Spaces 2*num-2*i-2 2*num-2*i-2
Value * i

Important Formulas in Part 9

Upper Increasing Leading Spaces

num - i

Lower Increasing Leading Spaces

p

Pattern-81 Lower Alphabet

chr(64+q+p)

Pattern-82 Increasing Number

n-i+j

Pattern-82 Reverse Number

n+1-k

Pattern-83 Decreasing Number

n+1-j

Increasing Hollow Inner Spaces

2*i - 4

Decreasing Hollow Inner Spaces

2*num - 2*i - 2

Increasing Number

i

Decreasing Number

num + 1 - i

Increasing Alphabet

chr(64+i)

Decreasing Alphabet

chr(64+num+1-i)

Part 9 — Execution Flow

                          START
                            │
                            ▼
                        Read num
                            │
                            ▼
                   Identify Pattern
                            │
          ┌─────────────────┼─────────────────┐
          │                 │                 │
          ▼                 ▼                 ▼
      Pattern-81        Pattern-82/83      Pattern-84/90
      Alphabet          Symmetrical          Hollow
      Combined            Numbers            Patterns
          │                 │                 │
          ▼                 ▼                 ▼
    Upper + Lower      Build Left Half    Print Leading
       Sections              │               Spaces
          │                  ▼                 │
          │            Build Right Half        ▼
          │                  │            Print Left
          │                  ▼             Boundary
          │            Upper + Lower            │
          │                Parts                ▼
          │                                  Print Inner
          │                                    Spaces
          │                                      │
          │                                      ▼
          │                                  Print Right
          │                                   Boundary
          │                                      │
          └──────────────────┬───────────────────┘
                             │
                             ▼
                            END

Part 9 — Important Notes

  • Pattern-81 continues the combined alphabet sequence family.
  • Pattern-81 uses chr(64+j) in the upper part.
  • The lower part of Pattern-81 uses chr(64+q+p) to shift the starting alphabet.
  • Pattern-82 creates a number diamond whose values increase toward the centre.
  • Pattern-83 creates the opposite number arrangement, decreasing toward the centre and then increasing.
  • The document's Pattern-83 program uses while True, so it repeatedly asks for another number.
  • Patterns 84–88 belong to the increasing hollow-pattern family.
  • Pattern-84 uses stars.
  • Patterns 85 and 86 use numbers.
  • Patterns 87 and 88 use alphabets.
  • The inner-space formula for Patterns 84–88 is 2*i-4.
  • The first row of an increasing hollow pattern contains only one boundary value.
  • Pattern-89 reverses the hollow star structure.
  • Pattern-90 uses increasing numbers with the decreasing hollow structure.
  • The decreasing hollow inner-space formula is 2*num-2*i-2.
  • range(i,i+1) executes exactly once.
  • chr() converts numeric character codes into alphabets.

Part 9 — Pattern Logic Summary

Pattern Type Main Logic
81 Combined Alphabet Sequence chr(64+j) / chr(64+q+p)
82 Symmetrical Number Diamond Increase then decrease
83 Reverse Symmetrical Number Diamond Decrease then increase
84 Hollow Star Increasing width
85 Hollow Number Increasing values
86 Hollow Number Decreasing values
87 Hollow Alphabet Decreasing alphabets
88 Hollow Alphabet Increasing alphabets
89 Hollow Star Decreasing width
90 Hollow Number Increasing number + decreasing width

Part 9 — Quick Revision

                    PATTERN 81-90
                          │
       ┌──────────────────┼──────────────────┐
       │                  │                  │
       ▼                  ▼                  ▼
   Pattern-81        Pattern-82/83       Pattern-84/90
   ALPHABET            NUMBER              HOLLOW
   COMBINED             DIAMONDS           PATTERNS
       │                  │                  │
       ▼                  ▼          ┌───────┴────────┐
Upper + Lower       Symmetrical       │                │
   Sections          Sequences         ▼                ▼
                                  Increasing        Decreasing
                                     Hollow            Hollow
                                       │                │
                                 Patterns 84-88    Patterns 89-90
                                       │                │
                         ┌─────────────┼───────┐        │
                         ▼             ▼       ▼        ▼
                       Stars        Numbers Alphabets Stars/Numbers

Introduction

Part 10 covers the final pattern programs from Pattern-91 to Pattern-100.

In this part, we will learn:

Pattern-91  → Inverted Hollow Decreasing Number Pattern
Pattern-92  → Inverted Hollow Decreasing Alphabet Pattern
Pattern-93  → Inverted Hollow Increasing Alphabet Pattern
Pattern-94  → Right-Shifted Star Rectangle
Pattern-95  → Double Increasing Star Triangle
Pattern-96  → Alternating 1 and 0 Triangle
Pattern-97  → Multi-Section Star Pattern
Pattern-98  → Even-Star Pyramid
Pattern-99  → Repeated Even-Length Star Rows
Pattern-100 → Large Multi-Section Star Pattern

The important concepts used are:

  • Nested loops
  • Increasing and decreasing spaces
  • Hollow patterns
  • Number patterns
  • Alphabet patterns using chr()
  • Binary patterns
  • Odd and even checking
  • Multiple pattern sections
  • String multiplication
  • Complex star structures

Pattern-91 — Inverted Hollow Decreasing Number Pattern

Pattern-91 continues the inverted hollow pattern family from Pattern-90.

Pattern-90 prints increasing numbers, whereas Pattern-91 prints decreasing numbers.

Output for num = 5

5       5
 4     4
  3   3
   2 2
    1

The numbers decrease:

5 → 4 → 3 → 2 → 1

At the same time:

  • Leading spaces increase.
  • Inner spaces decrease.
  • The two boundaries move toward each other.

Pattern-91 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-91 — Step-by-Step Explanation

Step 1 — Read Number

num=int(input("Enter a number:"))

Step 2 — Control Rows

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

For num = 5:

i = 1, 2, 3, 4, 5

Step 3 — Leading Spaces

" " * (i-1)

The spaces increase:

0, 1, 2, 3, 4

Step 4 — Calculate Number

num + 1 - i

For num = 5:

i = 1 → 5
i = 2 → 4
i = 3 → 3
i = 4 → 2
i = 5 → 1

Step 5 — Inner Spaces

2*num - 2*i - 2

The inner spaces gradually decrease.

Step 6 — Final Row

if i < num:

The second number is not printed on the final row.

Pattern-91 — Execution Flow

Read num
   │
   ▼
Start Row Loop
   │
   ▼
Print i-1 Spaces
   │
   ▼
Calculate num+1-i
   │
   ▼
Print Left Number
   │
   ▼
Is i < num?
   │
 ┌─┴────────────┐
 │ Yes          │ No
 ▼              ▼
Print Inner    Skip Second
Spaces         Number
 │
 ▼
Print Right Number
 │
 └──────┬───────┘
        ▼
     Next Row

Pattern-92 — Inverted Hollow Decreasing Alphabet Pattern

Pattern-92 converts Pattern-91 from numbers into alphabets.

Output for num = 5

E       E
 D     D
  C   C
   B B
    A

The alphabet sequence is:

E → D → C → B → A

Pattern-92 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-92 — Alphabet Formula

The important expression is:

chr(64 + num + 1 - i)

For num = 5:

i = 1 → chr(69) → E
i = 2 → chr(68) → D
i = 3 → chr(67) → C
i = 4 → chr(66) → B
i = 5 → chr(65) → A

Therefore, Pattern-92 is the alphabet version of Pattern-91.

Pattern-92 — Execution Flow

Read num
   │
   ▼
Start Row Loop
   │
   ▼
Print Leading Spaces
   │
   ▼
Calculate Alphabet
chr(64+num+1-i)
   │
   ▼
Print Left Alphabet
   │
   ▼
Print Inner Spaces
   │
   ▼
Print Right Alphabet
   │
   ▼
Next Row

Pattern-93 — Inverted Hollow Increasing Alphabet Pattern

Pattern-93 has the same inverted hollow structure, but alphabets increase from A onward.

Output for num = 5

A       A
 B     B
  C   C
   D D
    E

The sequence is:

A → B → C → D → E

Pattern-93 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-93 — Step-by-Step Explanation

The alphabet is generated using:

chr(64+i)

Therefore:

i = 1 → A
i = 2 → B
i = 3 → C
i = 4 → D
i = 5 → E

The document uses:

if i <= 4:

For the demonstrated value num = 5, this prevents a second E from appearing on the last row.

The inner-space formula is:

2*num - 2*i - 2

Pattern-91 to Pattern-93 — Comparison

Pattern Value Direction Expression
91 Number 5 → 1 num+1-i
92 Alphabet E → A chr(64+num+1-i)
93 Alphabet A → E chr(64+i)

Pattern-94 — Right-Shifted Star Rectangle

Pattern-94 prints the same number of stars in every row.

However, every new row gets one additional leading space.

Output for num = 5

* * * * *
 * * * * *
  * * * * *
   * * * * *
    * * * * *

This creates a slanted or right-shifted rectangle.

Pattern-94 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-94 — Program Explanation

The outer loop controls rows:

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

The leading spaces are:

i - 1

The inner loop always executes num times:

for j in range(1,num+1):

Therefore every row contains the same number of stars.

For num = 5

Row 1 → 0 leading spaces + 5 stars
Row 2 → 1 leading space  + 5 stars
Row 3 → 2 leading spaces + 5 stars
Row 4 → 3 leading spaces + 5 stars
Row 5 → 4 leading spaces + 5 stars

Pattern-94 — Execution Flow

Read num
   │
   ▼
Start Outer Loop
   │
   ▼
Print i-1 Spaces
   │
   ▼
Run Inner Loop num Times
   │
   ▼
Print *
   │
   ▼
Move to New Line
   │
   ▼
Next Row

Pattern-95 — Double Increasing Star Triangle

Pattern-95 prints two increasing star groups in every row.

Output for num = 5

        * *
      * * * *
    * * * * * *
  * * * * * * * *
* * * * * * * * * *

Each row contains:

Left Star Group + Spaces + Right Star Group

Both star groups increase together.

Pattern-95 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-95 — Step-by-Step Explanation

First, leading spaces are printed:

" " * (num-i)

Then the first star group is created:

for j in range(1,i+1):
    print("*",end=" ")

The middle spacing also uses:

" " * (num-i)

Finally, another star group is created:

for k in range(1,i+1):
    print("*",end=" ")

Star Counts

Row 1 → 1 + 1 = 2 stars
Row 2 → 2 + 2 = 4 stars
Row 3 → 3 + 3 = 6 stars
Row 4 → 4 + 4 = 8 stars
Row 5 → 5 + 5 = 10 stars

Pattern-95 — Execution Flow

Read num
   │
   ▼
Start Row
   │
   ▼
Print Leading Spaces
   │
   ▼
Print i Stars
   │
   ▼
Print Middle Spaces
   │
   ▼
Print i Stars Again
   │
   ▼
New Line

Pattern-96 — Alternating 1 and 0 Triangle

Pattern-96 is a binary triangle containing alternating 1 and 0.

Output

1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1
1 0 1 0 1 0 1

Every row contains exactly as many values as its row number.

Pattern-96 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-96 — Understanding the Condition

The most important condition is:

(i%2!=0 and j%2!=0) or (i%2==0 and j%2==0)

A 1 is printed when:

i is odd  AND j is odd

OR

i is even AND j is even

In simple words:

Same parity → 1
Different parity → 0

Pattern-96 — Condition Table

i j Condition Output
Odd Odd True 1
Odd Even False 0
Even Odd False 0
Even Even True 1

Pattern-96 — Row-by-Row Explanation

Row 1

i = 1

j = 1
Odd + Odd → 1

Output:
1

Row 2

i = 2

j = 1 → Even + Odd  → 0
j = 2 → Even + Even → 1

Output:
0 1

Row 3

i = 3

j = 1 → Odd + Odd  → 1
j = 2 → Odd + Even → 0
j = 3 → Odd + Odd  → 1

Output:
1 0 1

Pattern-96 — Execution Flow

Read n
   │
   ▼
Start Row Loop i
   │
   ▼
Start Column Loop j
   │
   ▼
Check Parity of i and j
   │
 ┌─┴────────────────┐
 │ Same             │ Different
 ▼                  ▼
Print 1           Print 0
 │                  │
 └────────┬─────────┘
          ▼
      Next Column
          │
          ▼
       New Line

Pattern-97 — Multi-Section Star Pattern

Pattern-97 is a special pattern created using multiple independent loop sections.

Unlike a normal triangle, this pattern combines several growing star sections followed by a vertical section.

The document builds this pattern using four loop blocks.

Pattern-97 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-97 — First Section

The first section is:

for i in range(1,num+1):
    print(" "*(2*num-i+3),end="")
    for j in range(1,i+1):
        print("*",end=" ")

The number of stars increases normally:

1, 2, 3, 4, 5 ...

The leading-space expression is:

2*num - i + 3

Pattern-97 — Second Section

The second block uses:

for i in range(1,num+3):

Its inner loop is:

for j in range(-1,i+1):

Because the range starts from -1, more iterations occur than in a standard range(1,i+1).

This creates a wider star section.

Pattern-97 — Third and Fourth Sections

The third section increases the width further using:

for j in range(-2,i+1):

The final section is:

for i in range(1,num+3):
    print(" "*(2*num),end="")
    print("* "*3)

This repeatedly prints:

* * *

at a fixed horizontal position, creating the final vertical portion of the design.

Pattern-97 — Execution Flow

Read num
   │
   ▼
Section 1
Normal Growing Triangle
   │
   ▼
Section 2
Wider Growing Triangle
   │
   ▼
Section 3
Still Wider Triangle
   │
   ▼
Section 4
Fixed 3-Star Rows
   │
   ▼
Final Combined Pattern

Pattern-98 — Even-Star Pyramid

Pattern-98 prints an increasing pyramid where every row contains an even number of stars.

Output for n = 5

        * *
      * * * *
    * * * * * *
  * * * * * * *
* * * * * * * * * *

The star counts are:

2
4
6
8
10

Pattern-98 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-98 — Step-by-Step Explanation

Leading Spaces

2 * (n-i)

For n = 5:

i = 1 → 8 spaces
i = 2 → 6 spaces
i = 3 → 4 spaces
i = 4 → 2 spaces
i = 5 → 0 spaces

Stars

"* " * (2*i)

The number of stars is:

i = 1 → 2
i = 2 → 4
i = 3 → 6
i = 4 → 8
i = 5 → 10

Therefore, the number of stars always remains even.

Pattern-98 — Execution Flow

Read n
   │
   ▼
Start Row Loop
   │
   ▼
Calculate 2*(n-i)
   │
   ▼
Print Leading Spaces
   │
   ▼
Calculate 2*i
   │
   ▼
Print Stars
   │
   ▼
Next Row

Pattern-99 — Repeated Even-Length Star Rows

Pattern-99 prints star rows in pairs.

Output for n = 5

**
**
****
****
******
******
********
********
**********
**********

Each even star count appears twice:

2 stars  → 2 times
4 stars  → 2 times
6 stars  → 2 times
8 stars  → 2 times
10 stars → 2 times

Pattern-99 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-99 — Understanding the Logic

The outer loop executes:

2 * n

times.

For n = 5:

i = 1 to 10

The program checks:

i % 2 == 0

If i is Even

print("*"*i)

If i is Odd

print("*"*(i+1))

Therefore:

i = 1 → i+1 = 2 → **
i = 2 → i   = 2 → **

i = 3 → i+1 = 4 → ****
i = 4 → i   = 4 → ****

i = 5 → i+1 = 6 → ******
i = 6 → i   = 6 → ******

This is why each even-sized row appears twice.

Pattern-99 — Execution Flow

Read n
   │
   ▼
Loop i from 1 to 2*n
   │
   ▼
Is i Even?
   │
 ┌─┴─────────────┐
 │ Yes           │ No
 ▼               ▼
Print i Stars   Print i+1 Stars
 │               │
 └───────┬───────┘
         ▼
      New Line
         │
         ▼
      Next i

Pattern-100 — Large Multi-Section Star Pattern

Pattern-100 is the final pattern in the document.

It is a large composite star pattern created by repeatedly generating growing star sections and finally adding a fixed-width vertical section.

The program uses:

  • An outer loop with a step value of 2
  • A nested row loop
  • Dynamic leading spaces
  • Dynamic star counts
  • A separate final loop

This makes Pattern-100 one of the more complex patterns in the chapter.

Pattern-100 — Complete Program

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Pattern-100 — Outer Loop

The first important loop is:

for a in range(1,n+1,2):

The third argument of range() is:

2

Therefore a increases by 2.

For example, if:

n = 5

then:

a = 1, 3, 5

This means the program creates multiple star sections with increasing starting widths.

Pattern-100 — Row Loop

Inside every value of a, another loop runs:

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

Therefore each major section contains n rows.

The leading spaces are calculated using:

2*n - i - a

As i increases, the leading spaces decrease.

As a increases, the complete section also shifts.

Pattern-100 — Star Loop

The stars are generated using:

for j in range(1,i+a):
    print("*",end=" ")

The number of iterations is approximately controlled by:

i + a - 1

Therefore both variables affect the width:

i → controls growth inside a section
a → controls starting width of each new section

Example

If:

a = 1

then the star counts grow approximately as:

1, 2, 3, 4, 5

If:

a = 3

the section begins wider:

3, 4, 5, 6, 7

Pattern-100 — Final Section

After all growing sections are completed, the document uses:

for b in range(1,n+1):
    print(" "*(n-2),end="")
    print("* "*3)

This loop executes n times.

Every iteration prints:

* * *

The number of leading spaces remains constant:

n - 2

Therefore this section creates a vertical block or trunk at the bottom of the complete pattern.

Pattern-100 — Execution Flow

                    START
                      │
                      ▼
                    Read n
                      │
                      ▼
          a = 1, 3, 5, ... n
                      │
                      ▼
             Run i from 1 to n
                      │
                      ▼
        Calculate Leading Spaces
              2*n-i-a
                      │
                      ▼
             Print Leading Spaces
                      │
                      ▼
          Run j from 1 to i+a
                      │
                      ▼
                 Print Stars
                      │
                      ▼
                 Next Row
                      │
                      ▼
               Next a Section
                      │
                      ▼
             Complete Sections
                      │
                      ▼
            Run Final b Loop
                      │
                      ▼
             Print Fixed Spaces
                      │
                      ▼
                Print * * *
                      │
                      ▼
                     END

Understanding the Hollow Pattern Family

Patterns 84 to 93 form an important hollow-pattern family.

The general idea is:

Left Boundary + Inner Spaces + Right Boundary

Increasing Hollow Shape

    *
   * *
  *   *
 *     *
*       *

Used in Patterns 84–88.

Decreasing Hollow Shape

*       *
 *     *
  *   *
   * *
    *

Used in Patterns 89–93.

Increasing vs Decreasing Hollow Space Formulas

Pattern Type Leading Spaces Inner Spaces
Increasing Hollow num-i 2*i-4
Decreasing Hollow i-1 2*num-2*i-2

For an increasing hollow pattern:

Leading spaces ↓
Inner spaces   ↑

For a decreasing hollow pattern:

Leading spaces ↑
Inner spaces   ↓

Pattern-90 to Pattern-93 — Value Comparison

Pattern Output Type Sequence
90 Numbers 1 → 5
91 Numbers 5 → 1
92 Alphabets E → A
93 Alphabets A → E

Understanding Odd and Even Checking

Patterns 96 and 99 make important use of the modulus operator.

Even Number

number % 2 == 0

Odd Number

number % 2 != 0

Pattern-96 compares the parity of the row and column positions.

Pattern-99 checks whether the current row counter is odd or even.

Important Formulas in Part 10

Increasing Leading Spaces

i - 1

Decreasing Hollow Inner Spaces

2*num - 2*i - 2

Decreasing Number

num + 1 - i

Decreasing Alphabet

chr(64 + num + 1 - i)

Increasing Alphabet

chr(64+i)

Pattern-95 Spaces

num - i

Pattern-98 Spaces

2*(n-i)

Pattern-98 Star Count

2*i

Pattern-100 Spaces

2*n-i-a

Pattern-100 Star Growth

range(1,i+a)

Pattern-91 to Pattern-100 — Complete Comparison

Pattern Pattern Type Main Concept
91 Hollow Number Decreasing numbers
92 Hollow Alphabet Decreasing alphabets
93 Hollow Alphabet Increasing alphabets
94 Star Rectangle Increasing leading spaces
95 Double Star Triangle Two increasing star groups
96 Binary Triangle Odd/even row-column checking
97 Special Star Pattern Multiple loop sections
98 Even-Star Pyramid 2, 4, 6, 8... stars
99 Repeated Star Rows Each even width appears twice
100 Complex Star Pattern Nested multi-section construction

Part 10 — Important Notes

  • Pattern-91 prints decreasing numbers in an inverted hollow structure.
  • Pattern-92 converts the same structure into decreasing alphabets.
  • Pattern-93 prints increasing alphabets.
  • The decreasing hollow inner-space formula is 2*num-2*i-2.
  • Pattern-94 prints a fixed number of stars while shifting each row toward the right.
  • Pattern-95 prints two star groups whose sizes increase together.
  • Pattern-96 introduces an alternating binary triangle.
  • Pattern-96 prints 1 when the row and column have matching parity.
  • Pattern-97 is built from four separate loop sections.
  • Pattern-98 always prints an even number of stars.
  • Pattern-98 uses 2*i for star count.
  • Pattern-99 prints every even-sized star row twice.
  • Pattern-99 uses i%2==0 to distinguish even and odd iterations.
  • Pattern-100 uses range(1,n+1,2), so the outer variable increases by 2.
  • Pattern-100 combines multiple growing sections with a final fixed-width section.
  • Pattern-100 is the final pattern in the uploaded document.

Part 10 — Quick Revision

                     PATTERN 91-100
                           │
        ┌──────────────────┼──────────────────┐
        │                  │                  │
        ▼                  ▼                  ▼
   Pattern 91-93      Pattern 94-95      Pattern 96-100
      HOLLOW              STAR              SPECIAL
      FAMILY            SHAPES             PATTERNS
        │                  │                  │
   ┌────┼────┐        ┌────┴────┐      ┌──────┼────────┐
   ▼    ▼    ▼        ▼         ▼      ▼      ▼        ▼
Number Alpha Alpha  Shifted   Double Binary Complex  Repeated
  ↓      ↓     ↑    Rectangle Triangle Triangle Stars  Stars

Pattern Programs Chapter — Final Summary

We have now completed the complete sequence of pattern programs from Pattern-1 to Pattern-100.

Across these 100 programs, we learned how to create:

  • Square patterns
  • Rectangular patterns
  • Increasing triangles
  • Decreasing triangles
  • Right-aligned triangles
  • Number patterns
  • Alphabet patterns
  • Increasing pyramids
  • Decreasing pyramids
  • Symmetrical pyramids
  • Diamond patterns
  • Combined upper and lower patterns
  • Hollow patterns
  • Binary patterns
  • Special multi-section star patterns

Core Pattern Programming Formula

Outer Loop
    │
    ├── Controls Rows
    │
    ▼
Spaces
    │
    ├── Control Alignment
    │
    ▼
Inner Loop
    │
    ├── Controls Columns / Values
    │
    ▼
Print *, Number or Alphabet
    │
    ▼
Move to Next Line

The most important skill in pattern programming is not memorizing the programs.

We should understand how the following values change from one row to another:

1. Number of rows
2. Number of columns
3. Number of leading spaces
4. Number of inner spaces
5. Number of printed values
6. Value printed at each position

Once these relationships are understood, complex patterns can be divided into smaller and easier sections.

🧠 Test Your Knowledge

131 Questions

Progress: 0 / 131
Keep Going!Course Complete!