Nearby lessons
56 of 159Python - Diamond and Symmetrical Patterns
- Split a shape into an upper and lower section
- Combine two loops to draw diamond and symmetrical shapes
- Handle alphabet sequences that grow then shrink
- Use the two types of symmetry to compare patterns
- Apply right-alignment formulas to increasing triangles
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
forloops - 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
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 |
|---|---|---|---|
| 1 | E | 0 | 9 |
| 2 | D | 1 | 7 |
| 3 | C | 2 | 5 |
| 4 | B | 3 | 3 |
| 5 | A | 4 | 1 |
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
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
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
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 |
|---|---|---|---|---|
| 1 | 4 | 1 | - | 1 |
| 2 | 3 | 1 2 | 1 | 1 2 1 |
| 3 | 2 | 1 2 3 | 2 1 | 1 2 3 2 1 |
| 4 | 1 | 1 2 3 4 | 3 2 1 | 1 2 3 4 3 2 1 |
| 5 | 0 | 1 2 3 4 5 | 4 3 2 1 | 1 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
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
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 | - | 0 | 0 |
| 2 | 1 | 0 1 | 1 0 1 |
| 3 | 2 1 | 0 1 2 | 2 1 0 1 2 |
| 4 | 3 2 1 | 0 1 2 3 | 3 2 1 0 1 2 3 |
| 5 | 4 3 2 1 | 0 1 2 3 4 | 4 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
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
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
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):
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
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):
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*ihelps 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
0as 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
forloops - 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
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):
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
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
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
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
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 |
|---|---|---|
| 1 | 4 | 1 |
| 2 | 3 | 2 |
| 3 | 2 | 3 |
| 4 | 1 | 4 |
| 5 | 0 | 5 |
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
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
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
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
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
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 |
|---|---|---|
| 1 | 0 | 5 |
| 2 | 1 | 4 |
| 3 | 2 | 3 |
| 4 | 3 | 2 |
| 5 | 4 | 1 |
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
iinto an alphabet usingchr(64+i). - Pattern-69 converts
jinto an alphabet usingchr(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
- Diamonds combine an increasing part and a decreasing part
- A single middle row is shared by the two halves
- Vertically symmetrical patterns mirror their upper half
- Right-aligned increasing triangles use a decreasing leading-space count