This article shows the list of important and frequently asked Number Pattern Programs in Python Programming Language with an example. Although there are multiple ways to write each Number Pattern Program in Python, we provide an example of a for loop to give an introduction. However, you can use the hyperlinks to see more examples using while loop, functions, and recursion.
In Python, apart from the Number Pattern Programs, there are Star and Alphabets programs, which we covered in separate articles. Please refer to the Python tutorial and Example articles to understand the syntax and coding. Also, refer to the Star and Alphabets program.
Python Number Pattern Programs
The following list of Python Number Pattern Programs is displayed in different shapes. Please use the Click Here hyperlink to go deeper into them.
Python Program to Print a Simple Number Pattern
For more programs on displaying the Simple Number Pattern >> Click Here!
n = int(input("Enter Simple Number Pattern Rows = ")) for i in range(1, n + 1): for j in range(1, i + 1): print(j, end = ' ') print()
Output
Enter Simple Number Pattern Rows = 10
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
Python Program to Print Diamond Number Pattern
For more programs on displaying the Diamond Number Pattern >> Click Here!
def internalLogic(rows, i): for j in range(1, rows - i + 1): print(end = ' ') for k in range(i, 0, -1): print(k, end = '') for l in range(2, i + 1): print(l, end = '') rows = int(input("Enter Diamond Number Pattern Rows = ")) for i in range(1, rows + 1): internalLogic(rows, i) print() for i in range(rows - 1, 0, -1): internalLogic(rows, i) print()
Output
Enter Diamond Number Pattern Rows = 8
1
212
32123
4321234
543212345
65432123456
7654321234567
876543212345678
7654321234567
65432123456
543212345
4321234
32123
212
1
Python Program to Print Floyd’s Triangle Number Pattern
For more programs on displaying the Floyd’s Triangle Numbers Pattern >> Click Here!
rows = int(input("Please Enter the total n of Rows : ")) n = 1 for i in range(1, rows + 1): for j in range(1, i + 1): print(n, end = ' ') n = n + 1 print()
Output
Please Enter the total n of Rows : 9
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
Python Program to Print Pascal Triangle
This section covers all the Pascal Triangle number pattern programs. The below example prints the Pascal Triangle. For more programs on displaying the Pascal Triangle Number Pattern >> Click Here!
from math import factorial n = int(input("Enter Pascals Triangle Number Pattern Rows = ")) for i in range(0, n): for j in range(n - i + 1): print(end = ' ') for k in range(0, i + 1): print(factorial(i)//(factorial(k) * factorial(i - k)), end = ' ') print()
Output
Enter Pascals Triangle Number Pattern Rows = 5
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Left Pascals Number Triangle Pattern
For more programs on displaying the Left Pascals Number Triangle Pattern >> Click Here!
def internalLogic(rows, i): for j in range(i, rows): print(end = ' ') for k in range(1, i + 1): print(k, end = ' ') print() rows = int(input("Enter Left Pascals Number Pattern Rows = ")) for i in range(1, rows + 1): internalLogic(rows, i) for i in range(rows - 1, 0, -1): internalLogic(rows, i)
Output
Enter Left Pascals Number Pattern Rows = 8
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
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Right Pascals Number Triangle Pattern
For more programs on displaying the Right Pascals Number Triangle Pattern >> Click Here!
def internalLogic(rows, i): for j in range(1, i + 1): print(j, end = ' ') print() rows = int(input("Enter Right Pascals Number Pattern Rows = ")) for i in range(1, rows + 1): internalLogic(rows, i) for i in range(rows - 1, 0, -1): internalLogic(rows, i)
Output
Enter Right Pascals Number Pattern Rows = 8
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
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Right Pascals Triangle of Multiplication Numbers Pattern
For more Python programs on printing the Right Pascals Triangle of Multiplication Number Pattern >> Click Here!
def internalLogic(rows, i): for j in range(1, i + 1): print(j * i, end = ' ') print() rows = int(input("Enter Right Pascals Rows = ")) for i in range(1, rows + 1): internalLogic(rows, i) for i in range(rows - 1, 0, -1): internalLogic(rows, i)
Output
Enter Right Pascals Rows = 6
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
5 10 15 20 25
4 8 12 16
3 6 9
2 4
1
Right Pascals Triangle of Mirrored Numbers Pattern
For more programs on displaying the Right Pascals Triangle of Mirrored Numbers Pattern >> Click Here!
def internalLogic(rows, i): for j in range(i, rows + 1): print(j, end = ' ') for k in range(rows - 1, i - 1, -1): print(k, end = ' ') print() rows = int(input("Enter Right Pascals Mirrored Numbers Rows = ")) for i in range(rows, 0, -1): internalLogic(rows, i) for i in range(2, rows + 1): internalLogic(rows, i)
Output
Enter Right Pascals Mirrored Numbers Rows = 7
7
6 7 6
5 6 7 6 5
4 5 6 7 6 5 4
3 4 5 6 7 6 5 4 3
2 3 4 5 6 7 6 5 4 3 2
1 2 3 4 5 6 7 6 5 4 3 2 1
2 3 4 5 6 7 6 5 4 3 2
3 4 5 6 7 6 5 4 3
4 5 6 7 6 5 4
5 6 7 6 5
6 7 6
7
Python Program to Print Pyramid Numbers Pattern
For more programs on displaying the Pyramid Number Pattern >> Click Here!
n = int(input("Enter Pyramid Number Pattern Rows = ")) for i in range(1, n + 1): for j in range(n, i, -1): print(end = ' ') for k in range(1, i + 1): print(i, end = ' ') print()
Output
Enter Pyramid Number Pattern Rows = 9
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
Python Program to Print Rectangle Number Pattern
This section covers all the rectangle number pattern programs. The below example prints the unique number in each row. For more programs on displaying the Rectangle Number Pattern >> Click Here!
rows = int(input("Enter Rows : ")) columns = int(input("Enter Columns : ")) for i in range(1, rows + 1): for j in range(1, columns + 1): print(i, end = ' ') print()
Output
Enter Rows : 8
Enter Columns : 14
1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6 6 6 6 6 6 6
7 7 7 7 7 7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8 8 8 8 8 8
Hollow Rectangle Number Pattern
For more programs on displaying the Hollow Rectangle Number Pattern >> Click Here!
rows = int(input("Enter Rows : ")) columns = int(input("Enter Columns : ")) for i in range(1, rows + 1): for j in range(1, columns + 1): if i == 1 or i == rows or j == 1 or j == columns: print(i, end = ' ') else: print(' ', end = ' ') print()
Output
Enter Rows : 7
Enter Columns : 9
1 1 1 1 1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7 7 7 7 7 7 7 7
1 and 0 in alternative Columns
For more programs on displaying the 1 and 0 Numbers in alternative Columns Patterns >> Click Here!
rows = int(input("Enter Rows = ")) columns = int(input("Enter Columns = ")) for i in range(1, rows + 1): for j in range(1, columns + 1): if(j % 2 == 0): print('0', end = ' ') else: print('1', end = ' ') print()
Output
Enter Rows = 6
Enter Columns = 9
1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1
1 and 0 in Alternative Rows
For more Python programs on printing the 0 and 1 Number in alternative rows Pattern >> Click Here!
rows = int(input("Enter Rows = ")) columns = int(input("Enter Columns = ")) for i in range(1, rows + 1): for j in range(1, columns + 1): if(i % 2 != 0): print('1', end = ' ') else: print('0', end = ' ') print()
Output
Enter Rows = 7
Enter Columns = 12
1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1
Box Number Pattern
For more programs on displaying the Box Number Pattern >> Click Here!
rows = int(input("Enter Rows = ")) columns = int(input("Enter Columns = ")) for i in range(1, rows + 1): for j in range(1, columns + 1): if(i == 1 or i == rows or j == 1 or j == columns): print('1', end = ' ') else: print('0', end = ' ') print()
Output
Enter Rows = 8
Enter Columns = 15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Hollow Box Pattern of Numbers
For more programs on displaying the Hollow Box Pattern of Numbers Pattern >> Click Here!
rows = int(input("Enter Rows = ")) columns = int(input("Enter Columns = ")) for i in range(1, rows + 1): for j in range(1, columns + 1): if(i == 1 or i == rows or j == 1 or j == columns): print('1', end = ' ') else: print(' ', end = ' ') print()
Output
If you replace the static 1 with i, the result of the hollow box will be completely different.
rows = int(input("Enter Rows = ")) columns = int(input("Enter Columns = ")) for i in range(1, rows + 1): for j in range(1, columns + 1): if(i == 1 or i == rows or j == 1 or j == columns): print(i, end = ' ') else: print(' ', end = ' ') print()
Output
Enter Rows = 7
Enter Columns = 12
1 1 1 1 1 1 1 1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7 7 7 7 7 7 7 7 7 7 7
Python Program to Print Right Triangle Number Pattern
This section covers different kinds of the Right Triangle number pattern programs. The below example prints the same number in each row. For more programs on displaying the Right Triangle Number Pattern >> Click Here!
rows = int(input("Enter Rows : ")) for i in range(1, rows + 1): for j in range(1, i + 1): print(i, end = ' ') print()
Output
Enter Rows : 9
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
Right Triangle of 1 and 0 Number Pattern
For more programs on displaying the Right Triangle of 1 and 0 Numbers Pattern >> Click Here!
n = int(input("Enter Right Triangle of 1 & 0 Pattern Rows = ")) for i in range(1, n + 1): for j in range(1, i + 1): if j % 2 == 0: print(0, end = ' ') else: print(1, end = ' ') print()
Output
Enter Right Triangle of 1 & 0 Pattern Rows = 13
1
1 0
1 0 1
1 0 1 0
1 0 1 0 1
1 0 1 0 1 0
1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1
Right Triangle of Incremented Numbers Pattern
For more programs on displaying the Right Triangle of Incremented Numbers Pattern >> Click Here!
n = int(input("Enter Right Triangle of Incremented Numbers Rows = ")) for i in range(1, n + 1): for j in range(i, 0, -1): print(j, end = ' ') print()
Output
Enter Right Triangle of Incremented Numbers Rows = 9
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
Right Triangle of Numbers in Reverse Pattern
For more Python programs on printing the Right Angled Triangle of Number in Reverse Pattern >> Click Here!
n = int(input("Right Triangle Reverse Numbers Rows = ")) for i in range(n, 0, -1): for j in range(n, i - 1, -1): print(j, end = ' ') print()
Output
Right Triangle Reverse Numbers Rows = 9
9
9 8
9 8 7
9 8 7 6
9 8 7 6 5
9 8 7 6 5 4
9 8 7 6 5 4 3
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3 2 1
Right Triangle of Numbers in Sine Wave Pattern
For more programs on displaying the Right Angled Triangle of Numbers in Sine Wave Pattern >> Click Here!
r = int(input("Enter Right Triangle Sine Wave Numbers Rows = ")) for i in range(1, r + 1): print(i, end = ' ') n = i for j in range(1, i): if j % 2 != 0: print((n + ((2 * (r - i + 1)) - 1)), end = ' ') n = n + (2 * (r - i + 1) - 1) else: print(n + 2 * (i - j), end = ' ') n = n + 2 * (i - j) print()
Output
Enter Right Triangle Sine Wave Numbers Rows = 8
1
2 15
3 14 16
4 13 17 26
5 12 18 25 27
6 11 19 24 28 33
7 10 20 23 29 32 34
8 9 21 22 30 31 35 36
Right Triangle of Mirrored Numbers Pattern
For more programs on displaying the Right Triangle of the Mirrored Numbers Pattern >> Click Here!
n = int(input("Enter Right Triangle Mirrored Numbers Rows = ")) for i in range(1, n + 1): for j in range(1, i + 1): print(j, end = ' ') for k in range(i - 1, 0, -1): print(k, end = ' ') print()
Output
Enter Right Triangle Mirrored Numbers Rows = 9
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
1 2 3 4 5 6 5 4 3 2 1
1 2 3 4 5 6 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
Consecutive Column Numbers in Right Triangle Pattern
For more programs on displaying the Consecutive Column Numbers in Right Angled Triangle Pattern >> Click Here!
n = int(input("Enter Right Triangle Pattern Rows = ")) val = 0 for i in range(1, n + 1): for j in range(1, i + 1): val = val + 1 if val < 10: print('0' + str(val), end = ' ') else: print(val, end = ' ') print()
Output
Enter Right Triangle Pattern Rows = 12
01
02 03
04 05 06
07 08 09 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
67 68 69 70 71 72 73 74 75 76 77 78
Consecutive Rows Numbers in Right Triangle Pattern
For more Python programs on displaying the Consecutive Rows Number in the Right Angled Triangle Pattern >> Click Here!
n = int(input("Enter Right Triangle Pattern Rows = ")) for i in range(1, n + 1): val = i for j in range(1, i + 1): print(val, end = ' ') val = val + n - j print()
Output
Enter Right Triangle Pattern Rows = 13
1
2 14
3 15 26
4 16 27 37
5 17 28 38 47
6 18 29 39 48 56
7 19 30 40 49 57 64
8 20 31 41 50 58 65 71
9 21 32 42 51 59 66 72 77
10 22 33 43 52 60 67 73 78 82
11 23 34 44 53 61 68 74 79 83 86
12 24 35 45 54 62 69 75 80 84 87 89
13 25 36 46 55 63 70 76 81 85 88 90 91
Inverted Right Triangle of Numbers Pattern
For more programs on displaying the Inverted Right Triangle of Numbers Pattern >> Click Here!
n = int(input("Enter Right Triangle Pattern Rows = ")) for i in range(n, 0, -1): for j in range(1, i + 1): if i < 10: print('0' + str(i), end = ' ') else: print(i, end = ' ') print()
Output
Enter Right Triangle Pattern Rows = 12
12 12 12 12 12 12 12 12 12 12 12 12
11 11 11 11 11 11 11 11 11 11 11
10 10 10 10 10 10 10 10 10 10
09 09 09 09 09 09 09 09 09
08 08 08 08 08 08 08 08
07 07 07 07 07 07 07
06 06 06 06 06 06
05 05 05 05 05
04 04 04 04
03 03 03
02 02
01
Inverted Right Triangle of Consecutive Numbers Pattern
For more programs on displaying the Inverted Right Triangle of Consecutive Numbers Pattern >> Click Here!
n = int(input("Inverted Right Triangle Rows = ")) for i in range(n, 0, -1): for j in range(1, i + 1): print(j, end = ' ') print()
Output
Inverted Right Triangle Rows = 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Inverted Right Triangle of Decreasing Order Numbers Pattern
For more programs on displaying the Inverted Right Triangle of Decreasing Order Numbers Pattern >> Click Here!
n = int(input("Inverted Right Triangle Numbers in Decreasing Rows = ")) for i in range(n, 0, -1): for j in range(i, 0, -1): if j < 10: print('0' + str(j), end = ' ') else: print(j, end = ' ') print()
Output
Inverted Right Triangle Numbers in Decreasing Rows = 13
13 12 11 10 09 08 07 06 05 04 03 02 01
12 11 10 09 08 07 06 05 04 03 02 01
11 10 09 08 07 06 05 04 03 02 01
10 09 08 07 06 05 04 03 02 01
09 08 07 06 05 04 03 02 01
08 07 06 05 04 03 02 01
07 06 05 04 03 02 01
06 05 04 03 02 01
05 04 03 02 01
04 03 02 01
03 02 01
02 01
01
Inverted Right Triangle Numbers in Reverse Pattern
For more programs on displaying the Inverted Right Triangle Numbers in Reverse Pattern >> Click Here!
n = int(input("Inverted Right Triangle Numbers Rows = ")) for i in range(1, n + 1): for j in range(n, i - 1, -1): if j < 10: print('0' + str(j), end = ' ') else: print(j, end = ' ') print()
Output
Inverted Right Triangle Numbers Rows = 16
16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01
16 15 14 13 12 11 10 09 08 07 06 05 04 03 02
16 15 14 13 12 11 10 09 08 07 06 05 04 03
16 15 14 13 12 11 10 09 08 07 06 05 04
16 15 14 13 12 11 10 09 08 07 06 05
16 15 14 13 12 11 10 09 08 07 06
16 15 14 13 12 11 10 09 08 07
16 15 14 13 12 11 10 09 08
16 15 14 13 12 11 10 09
16 15 14 13 12 11 10
16 15 14 13 12 11
16 15 14 13 12
16 15 14 13
16 15 14
16 15
16
Right Triangle of Fibonacci Series Numbers Pattern
For more programs on displaying the Right Triangle of Fibonacci Series Numbers Pattern >> Click Here!
rows = int(input("Enter Right Triangle of Fibonacci Numbers Rows = ")) for i in range(1, rows + 1): n1 = 0 n2 = 1 for j in range(1, i + 1): Next = n1 + n2 print(Next, end = ' ') n1 = n2 n2 = Next print()
Output
Enter Right Triangle of Fibonacci Numbers Rows = 8
1
1 2
1 2 3
1 2 3 5
1 2 3 5 8
1 2 3 5 8 13
1 2 3 5 8 13 21
1 2 3 5 8 13 21 34
Downward Triangle Mirrored Numbers Pattern
For more programs on displaying the Downward Triangle Mirrored Numbers Pattern >> Click Here!
n = int(input("Enter Downward Triangle Mirrored Numbers Rows = ")) for i in range(1, n + 1): for j in range(i, n + 1): print(j, end = ' ') for k in range(n - 1, i - 1, -1): print(k, end = ' ') print()
Output
Enter Downward Triangle Mirrored Numbers Rows = 9
1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
2 3 4 5 6 7 8 9 8 7 6 5 4 3 2
3 4 5 6 7 8 9 8 7 6 5 4 3
4 5 6 7 8 9 8 7 6 5 4
5 6 7 8 9 8 7 6 5
6 7 8 9 8 7 6
7 8 9 8 7
8 9 8
9
Python Program to Print Square Number Pattern
This section covers different kinds of the Square number pattern programs. The below example prints the same number on all sides of a square. For more programs on displaying the Square Number Pattern >> Click Here!
side = int(input("Enter any Side of a Square : ")) for i in range(side): for i in range(side): print('1', end = ' ') print()
Output
Enter any Side of a Square : 11
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1
Same Numbers on all Sides of a Square Pattern
For more programs on displaying the Same Numbers on all Sides of a Square Pattern >> Click Here!
def internalLogic(rows, i): for j in range(1, rows + 1): if i < j: print(rows - i + 1, end = '') else: print(rows - j + 1, end = '') for k in range(rows - 1, 0, - 1): if i < k: print(rows - i + 1, end = '') else: print(rows - k + 1, end = '') rows = int(input("Enter Square Number Pattern Rows = ")) for i in range(1, rows + 1): internalLogic(rows, i) print() for i in range(rows - 1, 0, -1): internalLogic(rows, i) print()
Output
Enter Square Number Pattern Rows = 8
888888888888888
877777777777778
876666666666678
876555555555678
876544444445678
876543333345678
876543222345678
876543212345678
876543222345678
876543333345678
876544444445678
876555555555678
876666666666678
877777777777778
888888888888888
Same Numbers in Square Rows and Columns Pattern
For more programs on displaying the Same Numbers in Square Rows and Columns Pattern >> Click Here!
n = int(input("Enter Same Number Rows & Columns Square Pattern Rows = ")) for i in range(1, n + 1): for j in range(i, n + 1): print(j, end = ' ') for k in range(1, i): print(k, end = ' ') print()
Output
Enter Same Number Rows & Columns Square Pattern Rows = 9
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8
Square With Diagonal Numbers Pattern
For more programs on displaying the Square With Diagonal Numbers Pattern >> Click Here!
n = int(input("Enter Square With Diagonal Numbers Rows = ")) for i in range(1, n + 1): for j in range(1, i): print('0', end = ' ') print(i, end = ' ') for k in range(i, n): print('0', end = ' ') print()
Output
Enter Square With Diagonal Numbers Rows = 9
1 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0
0 0 0 4 0 0 0 0 0
0 0 0 0 5 0 0 0 0
0 0 0 0 0 6 0 0 0
0 0 0 0 0 0 7 0 0
0 0 0 0 0 0 0 8 0
0 0 0 0 0 0 0 0 9
Square of Left Decrement Numbers Pattern
For more programs on displaying the Square of Left Decrement Numbers Pattern >> Click Here!
n = int(input("Enter Square of Left Decrement Numbers Rows = ")) for i in range(n, 0, -1): for j in range(i, n): print(j, end = ' ') for k in range(n - i, n): print(n, end = ' ') print()
Output
Enter Square of Left Decrement Numbers Rows = 9
9 9 9 9 9 9 9 9 9
8 9 9 9 9 9 9 9 9
7 8 9 9 9 9 9 9 9
6 7 8 9 9 9 9 9 9
5 6 7 8 9 9 9 9 9
4 5 6 7 8 9 9 9 9
3 4 5 6 7 8 9 9 9
2 3 4 5 6 7 8 9 9
1 2 3 4 5 6 7 8 9
Square of Right Increment Numbers Pattern
For more programs on displaying the Square of Right Increment Numbers Pattern >> Click Here!
n = int(input("Enter Square of Right Increment Numbers Rows = ")) for i in range(1, n + 1): for j in range(1, n - i + 1): print(1, end = ' ') for k in range(1, i + 1): print(i, end = ' ') print()
Output
Enter Square of Right Increment Numbers Rows = 9
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 2 2
1 1 1 1 1 1 3 3 3
1 1 1 1 1 4 4 4 4
1 1 1 1 5 5 5 5 5
1 1 1 6 6 6 6 6 6
1 1 7 7 7 7 7 7 7
1 8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9
Square Pattern of Left Shift Numbers
For more programs on displaying the Square Pattern of Left Shift Numbers >> Click Here!
n = int(input("Enter Square of Left Shift Numbers Rows = ")) for i in range(1, n + 1): for j in range(i, n + 1): print(j, end = ' ') for k in range(1, i): print(k, end = ' ') print()
Output
Enter Square of Left Shift Numbers Rows = 9
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8
Square Pattern of Left Rotating Odd Numbers
For more programs on displaying the Square Pattern of Left Rotating Odd Numbers >> Click Here!
n = int(input("Enter Square of Left Shift Odd Numbers Rows = ")) for i in range(1, n + 1): for j in range(i - 1, n): print(j * 2 + 1, end = ' ') for k in range(0, i - 1): print(k * 2 + 1, end = ' ') print()
Output
Enter Square of Left Shift Odd Numbers Rows = 12
1 3 5 7 9 11 13 15 17 19 21 23
3 5 7 9 11 13 15 17 19 21 23 1
5 7 9 11 13 15 17 19 21 23 1 3
7 9 11 13 15 17 19 21 23 1 3 5
9 11 13 15 17 19 21 23 1 3 5 7
11 13 15 17 19 21 23 1 3 5 7 9
13 15 17 19 21 23 1 3 5 7 9 11
15 17 19 21 23 1 3 5 7 9 11 13
17 19 21 23 1 3 5 7 9 11 13 15
19 21 23 1 3 5 7 9 11 13 15 17
21 23 1 3 5 7 9 11 13 15 17 19
23 1 3 5 7 9 11 13 15 17 19 21
Square of Right Decrement Numbers Pattern
For more programs on displaying the Square of Right Decrement Numbers Pattern >> Click Here!
n = int(input("Enter Square of Right Decrement Numbers Rows = ")) for i in range(n, 0, -1): for j in range(n, i - 1, -1): print(j, end = ' ') for k in range(n - i + 1, n): print(i, end = ' ') print()
Output
Enter Square of Right Decrement Numbers Rows = 9
9 9 9 9 9 9 9 9 9
9 8 8 8 8 8 8 8 8
9 8 7 7 7 7 7 7 7
9 8 7 6 6 6 6 6 6
9 8 7 6 5 5 5 5 5
9 8 7 6 5 4 4 4 4
9 8 7 6 5 4 3 3 3
9 8 7 6 5 4 3 2 2
9 8 7 6 5 4 3 2 1
Square Numbers in Sine Wave Pattern
For more programs on displaying the Square Numbers in Sine Wave Pattern >> Click Here!
n = int(input("Enter Square Numbers in Sine Wave Rows = ")) for i in range(n): for j in range(n): if j % 2 == 0: print((n * j) + i + 1, end = ' ') else: print(n * (j + 1) - i, end = ' ') print()
Output
Enter Square Numbers in Sine Wave Rows = 9
1 18 19 36 37 54 55 72 73
2 17 20 35 38 53 56 71 74
3 16 21 34 39 52 57 70 75
4 15 22 33 40 51 58 69 76
5 14 23 32 41 50 59 68 77
6 13 24 31 42 49 60 67 78
7 12 25 30 43 48 61 66 79
8 11 26 29 44 47 62 65 80
9 10 27 28 45 46 63 64 81
Python Program to Print Triangle Numbers Pattern
This section covers different kinds of Triangle number pattern programs. For more programs on displaying the Triangle Number Pattern >> Click Here!
n = int(input("Enter Triangle Numbers Pattern Rows = ")) for i in range(1, n + 1): for j in range(n, i, -1): print(end = ' ') for k in range(1, i + 1): print(k, end = ' ') print()
Output
Enter Triangle Numbers Pattern Rows = 8
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
Triangle of Numbers in Reverse Pattern
For more programs on displaying the Triangle of Numbers in Reverse Pattern >> Click Here!
n = int(input("Enter Triangle Reverse Numbers Pattern Rows = ")) for i in range(n, 0, -1): for j in range(1, i): print(end = ' ') for k in range(i, n + 1): print(k, end = ' ') print()
Output
Enter Triangle Reverse Numbers Pattern Rows = 9
9
8 9
7 8 9
6 7 8 9
5 6 7 8 9
4 5 6 7 8 9
3 4 5 6 7 8 9
2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
Inverted Triangle Numbers Pattern
For more programs on displaying the Inverted Triangle Numbers Pattern >> Click Here!
n = int(input("Enter Inverted Triangle Number Pattern Rows = ")) for i in range(1, n + 1): for j in range(1, i): print(end = ' ') for k in range(1, n - i + 2): print(k, end = ' ') print()
Output
Enter Inverted Triangle Number Pattern Rows = 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Triangle of Mirrored Numbers Pattern
For more programs on displaying the Triangle of Mirrored Numbers Pattern >> Click Here!
n = int(input("Enter Triangle Mirrored Numbers Rows = ")) for i in range(1, n + 1): for j in range(n, i, -1): print(end = ' ') for k in range(1, i + 1): print(k, end = '') for l in range(i - 1, 0, -1): print(l, end = '') print()
Output
Enter Triangle Mirrored Numbers Rows = 9
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321
Remaining Number Pattern Programs in Python
The following are the remaining Number Pattern Programs of different shapes in Python Programming Language.
K Shape Number Pattern
For more programs on displaying the K Shape Number Pattern >> Click Here!
def internalLogic(rows, i): for j in range(1, i + 1): print(j, end = ' ') print() rows = int(input("Enter K Shape Number Pattern Rows = ")) for i in range(rows, 0, -1): internalLogic(rows, i) for i in range(2, rows + 1): internalLogic(rows, i)
Output
Enter K Shape Number Pattern Rows = 7
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
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
Right Arrow Numbers Pattern
For more programs on displaying the Right Arrow Numbers Pattern >> Click Here!
n = int(input("Enter Right Arrow Number Pattern Rows = ")) for i in range(1, n + 1): for j in range(1, n + 1): if j < i: print(end = ' ') else: print(j, end = ' ') print() for i in range(1, n): for j in range(1, n + 1): if j < n - i: print(end = ' ') else: print(j, end = ' ') print()
Output
Enter Right Arrow Number Pattern Rows = 8
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8
3 4 5 6 7 8
4 5 6 7 8
5 6 7 8
6 7 8
7 8
8
7 8
6 7 8
5 6 7 8
4 5 6 7 8
3 4 5 6 7 8
2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Left Arrow Numbers Pattern
For more programs on displaying the Left Arrow Numbers Pattern >> Click Here!
def internalLogic(rows, i): for j in range(i, 0, -1): print(j, end = '') print() rows = int(input("Enter Left Arrow of Numbers Pattern Rows = ")) for i in range(rows, 0, -1): internalLogic(rows, i) for i in range(2, rows + 1): internalLogic(rows, i)
Output
Enter Left Arrow of Numbers Pattern Rows = 7
7654321
654321
54321
4321
321
21
1
21
321
4321
54321
654321
7654321
V Numbers Pattern
For more programs on displaying the V Numbers Pattern >> Click Here!
n = int(input("Enter V Number Pattern Rows = ")) for i in range(1, n + 1): for j in range(1, i + 1): print(j, end = '') for k in range(1, 2 * (n - i) + 1): print(end = ' ') for l in range(i, 0, -1): print(l, end = '') print()
Output
Enter V Number Pattern Rows = 9
1 1
12 21
123 321
1234 4321
12345 54321
123456 654321
1234567 7654321
12345678 87654321
123456789987654321
Sandglass Number Pattern
For more Python programs on displaying the Sandglass Number Pattern >> Click Here!
def internalLogic(rows, i): for j in range(1, i): print(end = ' ') for k in range(i, rows + 1): print(k, end = ' ') print() rows = int(input("Enter Sandglass Numbers Pattern Rows = ")) for i in range(1, rows + 1): internalLogic(rows, i) for i in range(rows - 1, 0, -1): internalLogic(rows, i)
Output
Enter Sandglass Numbers Pattern Rows = 8
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8
3 4 5 6 7 8
4 5 6 7 8
5 6 7 8
6 7 8
7 8
8
7 8
6 7 8
5 6 7 8
4 5 6 7 8
3 4 5 6 7 8
2 3 4 5 6 7 8
1 2 3 4 5 6 7 8