Nearby lessons

57 of 159

Python - Combined and Hollow Patterns

📌 What You Will Learn
  • Build combined diamond patterns from two triangle halves
  • Understand why range(1, num) is used in the lower part
  • Create hollow patterns by printing borders instead of filled areas
  • Apply inner-space formulas to increasing and decreasing hollow shapes
  • Compare solid and hollow versions of the same shape

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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(i-1),end="")
4 for j in range(1,num+2-i):
5 print(num-i+1,end=" ")
6 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(i-1),end="")
4 for j in range(1,num+2-i):
5 print(num+2-i-j,end=" ")
6 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(i-1),end="")
4 for j in range(1,num+2-i):
5 print(chr(65+num-i),end=" ")
6 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(i-1),end="")
4 for j in range(num+1-i,0,-1):
5 print(chr(64+j),end=" ")
6 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(i-1),end="")
4 for j in range(1,num+2-i):
5 print(chr(64+j),end=" ")
6 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 for j in range(1,i+1):
5 print("*",end=" ")
6 print()
7 
8for p in range(1,num):
9 print(" "*p,end="")
10 for q in range(1,num+1-p):
11 print("*",end=" ")
12 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 for j in range(1,i+1):
5 print(i,end=" ")
6 print()
7 
8for p in range(1,num):
9 print(" "*p,end="")
10 for q in range(1,num+1-p):
11 print(num-p,end=" ")
12 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 for j in range(1,i+1):
5 print(j,end=" ")
6 print()
7 
8for p in range(1,num):
9 print(" "*p,end="")
10 for q in range(1,num+1-p):
11 print(q+p,end=" ")
12 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 for j in range(1,i+1):
5 print(j,end=" ")
6 print()
7 
8for p in range(1,num):
9 print(" "*p,end="")
10 for q in range(1,num+1-p):
11 print(q,end=" ")
12 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 for j in range(1,i+1):
5 print(chr(64+i),end=" ")
6 print()
7 
8for p in range(1,num):
9 print(" "*p,end="")
10 for q in range(1,num+1-p):
11 print(chr(64+num-p),end=" ")
12 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 for j in range(1,i+1):
5 print(chr(64+j),end=" ")
6 print()
7 
8for p in range(1,num):
9 print(" "*p,end="")
10 for q in range(1,num+1-p):
11 print(chr(64+q+p),end=" ")
12 print()
Output
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

🐍Code Cell
1n=int(input("Enter a number:"))
2for i in range(1,n+1):
3 print(" "*(n-i),end="")
4 for j in range(1,i+1):
5 print(n-i+j,end=" ")
6 for k in range(2,i+1):
7 print(n+1-k,end=" ")
8 print()
9 
10for i in range(1,n+1):
11 print(" "*i,end="")
12 for j in range(1+i,n+1):
13 print(j,end=" ")
14 for k in range(2,n+1-i):
15 print(n+1-k,end=" ")
16 print()
Output
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

🐍Code Cell
1n=int(input("Enter a number:"))
2 
3for i in range(1,n+1):
4 print(" "*(n-i),end="")
5 
6 for j in range(1,i+1):
7 print(n+1-j,end=" ")
8 
9 for k in range(2,i+1):
10 print(n-i+k,end=" ")
11 
12 print()
13 
14for i in range(1,n+1):
15 print(" "*i,end="")
16 
17 for j in range(1,n+1-i):
18 print(n+1-j,end=" ")
19 
20 for k in range(2,n+1-i):
21 print(i+k,end=" ")
22 
23 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 
5 for j in range(i,i+1):
6 print("*",end=" ")
7 
8 if i>=2:
9 print(" "*(2*i-4),end="")
10 
11 for k in range(i,i+1):
12 print("*",end=" ")
13 
14 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 
5 for j in range(i,i+1):
6 print(i,end=" ")
7 
8 if i>=2:
9 print(" "*(2*i-4),end="")
10 
11 for k in range(i,i+1):
12 print(i,end=" ")
13 
14 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 
5 for j in range(i,i+1):
6 print(num+1-i,end=" ")
7 
8 if i>=2:
9 print(" "*(2*i-4),end="")
10 
11 for k in range(i,i+1):
12 print(num+1-i,end=" ")
13 
14 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 
5 for j in range(i,i+1):
6 print(chr(64+num+1-i),end=" ")
7 
8 if i>=2:
9 print(" "*(2*i-4),end="")
10 
11 for k in range(i,i+1):
12 print(chr(64+num+1-i),end=" ")
13 
14 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(num-i),end="")
4 
5 for j in range(i,i+1):
6 print(chr(64+i),end=" ")
7 
8 if i>=2:
9 print(" "*(2*i-4),end="")
10 
11 for k in range(i,i+1):
12 print(chr(64+i),end=" ")
13 
14 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(i-1),end="")
4 
5 for j in range(i,i+1):
6 print("*",end=" ")
7 
8 if i < num:
9 print(" "*(2*num-2*i-2),end="")
10 
11 for k in range(i,i+1):
12 print("*",end=" ")
13 
14 print()
Output
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

🐍Code Cell
1num=int(input("Enter a number:"))
2for i in range(1,num+1):
3 print(" "*(i-1),end="")
4 
5 for j in range(i,i+1):
6 print(i,end=" ")
7 
8 if i<num:
9 print(" "*(2*num-2*i-2),end="")
10 
11 for k in range(i,i+1):
12 print(i,end=" ")
13 
14 print()
Output
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
📝 Key Takeaways
  • Combined patterns grow in the upper half and shrink in the lower half
  • Hollow patterns print characters only on the boundary
  • range(i, i+1) executes exactly once
  • Leading and inner spaces are controlled by separate formulas

🧠 Test Your Knowledge

34 Questions
Progress: 0 / 34