Python Patterns Programs
Python Patterns Programs
*
* *
* * *
* * * *
* * * * *
*****
****
***
**
*
http://127.0.0.1:5500/index.html Page 1 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
3. Pyramid Pattern
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
*********
*******
*****
***
*
5. Diamond Pattern
http://127.0.0.1:5500/index.html Page 2 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
for i in range(5):
for j in range(5):
if i == 0 or i == 4 or j == 0 or j == 4:
print('*', end='')
else:
print(' ', end='')
print()
***** * * *
* * * *****
http://127.0.0.1:5500/index.html Page 3 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
for i in range(5):
print('*' * 5)
***** *****
***** *****
*****
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
http://127.0.0.1:5500/index.html Page 4 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
num = 1
for i in range(1, 6):
for j in range(1, i + 1):
print(num, end=' ')
num += 1
print()
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
http://127.0.0.1:5500/index.html Page 5 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*
*
*
* *
*
*****
*
*
* *
* *
* *
*********
n = 5
for i in range(1, n + 1):
http://127.0.0.1:5500/index.html Page 6 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*
* *
* *
* *
*********
* *
* *
* *
*
n = 5
for i in range(1, n + 1):
for j in range(1, n - i + 1):
print(' ', end='')
for j in range(1, 2 * i):
if j == 1 or j == 2 * i - 1:
print(i, end='')
else:
print(' ', end='')
print()
1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
http://127.0.0.1:5500/index.html Page 7 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
* * ** ** ***
*** **** ****
********* ****
**** *** *** **
** * *
http://127.0.0.1:5500/index.html Page 8 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
else:
print(' ', end='')
print()
1
2 2
3 3
4 4
5 5
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
*********
*******
http://127.0.0.1:5500/index.html Page 9 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*****
***
*
*
* *
* * *
* * * *
* * * * *
* * *
* * *
* * * *
* * * * *
http://127.0.0.1:5500/index.html Page 10 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
n = 5
for i in range(n):
for j in range(n - i - 1):
print(' ', end='')
for j in range(i + 1):
print(str(math.comb(i, j)) + ' ', end='')
print()
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
*
*
*
*
*
http://127.0.0.1:5500/index.html Page 11 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*********
*******
*****
***
*
***
*****
*******
*********
1
2 2 2
3 3 3 3 3
4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5
4 4 4 4 4 4 4
3 3 3 3 3
2 2 2
1
http://127.0.0.1:5500/index.html Page 12 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
***** * * *
* * * *****
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
http://127.0.0.1:5500/index.html Page 13 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1
http://127.0.0.1:5500/index.html Page 14 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
http://127.0.0.1:5500/index.html Page 15 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
1 1 2
1 2 3
1 2 3 4
1 2 3 4 5
for i in range(5):
for j in range(5):
if (i + j) % 2 == 0:
print('*', end='')
else:
print(' ', end='')
print()
* * *
* *
* * *
* *
* * *
import math
for i in range(1, 6):
for j in range(1, 6):
if math.dist([i, j], [3, 3]) <= 2:
print('*', end='')
else:
http://127.0.0.1:5500/index.html Page 16 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*****
* *
* *
* *
*****
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
http://127.0.0.1:5500/index.html Page 17 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
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
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
http://127.0.0.1:5500/index.html Page 18 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*********
* *
* *
* *
*
for i in range(5):
for j in range(5):
if i == j or i + j == 4:
print('*', end='')
else:
print(' ', end='')
print()
* *
* *
*
* *
* *
http://127.0.0.1:5500/index.html Page 19 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
* * *
* * *
* * * *
* * * * *
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
http://127.0.0.1:5500/index.html Page 20 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*
* *
* *
* *
*****
***** ****
*** ** *
http://127.0.0.1:5500/index.html Page 21 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
for i in range(5):
print(' ' * i + '*' * 5)
*****
*****
*****
*****
*****
for i in range(5):
print(' ' * (5 - i) + '*' * 5)
*****
*****
*****
*****
*****
http://127.0.0.1:5500/index.html Page 22 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
*****
* *
* *
*
*
* *
* *
*****
*********
* *
* *
* *
*
http://127.0.0.1:5500/index.html Page 23 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1
for i in range(5):
for j in range(1, 6):
print(j, end=' ')
print()
1 2 3 4 5
http://127.0.0.1:5500/index.html Page 24 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
1 2 3 4 5 1 2 3 4
5 1 2 3 4 5 1 2 3
4 5
*****
****
***
**
*
1 1 2
1 2 3
1 2 3 4
1 2 3 4 5
http://127.0.0.1:5500/index.html Page 25 of 26
Curious_.Programmer | CodeWithCurious.com
50 Python Pattern Programs - CodeWithCurious 13/01/25, 10:00
Link in BIO
http://127.0.0.1:5500/index.html Page 26 of 26
Curious_.Programmer | CodeWithCurious.com