KEMBAR78
Pattern Programs Part 3 | PDF | Software Engineering | Computer Programming
0% found this document useful (0 votes)
6 views5 pages

Pattern Programs Part 3

The document contains Python code for generating various patterns based on user-defined row numbers. Each pattern is demonstrated with a corresponding code snippet, showcasing different arrangements of numbers and letters. The patterns include triangular, inverted, and mirrored formats.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Pattern Programs Part 3

The document contains Python code for generating various patterns based on user-defined row numbers. Each pattern is demonstrated with a corresponding code snippet, showcasing different arrangements of numbers and letters. The patterns include triangular, inverted, and mirrored formats.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Leela Soft Python Patterns Madhu

'''
Pattern-30:
* * * * *
* * * *
* * *
* *
*
'''

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


for i in range(1,n+1):
print(" "*(i-1),"* "*(n+1-i))

'''
Pattern-31:
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
'''
n = int(input("Enter the number of rows: "))
for i in range(1, n + 1):
print(" "*(i - 1), (str(n + 1 - i) + " ") * (n + 1 - i))

'''
Pattern-31:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
'''
n=int(input("Enter the number of rows: "))
for i in range(1,n+1):
print(" "*(i-1),end="")
for j in range(1,n+2-i):
print(j,end=" ")
print()

'''
Pattern-33:
E E E E E
D D D D
C C C

www.leelasoft.com Cell: 78 42 66 47 66
Leela Soft Python Patterns Madhu

B B
A
'''
n=int(input("Enter the number of rows: "))
for i in range(1,n+1):
print(" "*(i-1),(str(chr(65+n-i))+" ")*(n+1-i))

'''
Pattern-34:
A B C D E
A B C D
A B C
A B
A
'''

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


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

'''
Pattern-35:
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
'''

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


for i in range(1, n + 1):
print(" "*(n - i), "* "*(2 * i - 1))

'''
Pattern-36:
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
'''
n = int(input("Enter the number of rows: "))

www.leelasoft.com Cell: 78 42 66 47 66
Leela Soft Python Patterns Madhu

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


print(" "*(n - i), (str(i) + " ") * (2 * i - 1))

'''
Pattern-37:
A
B B B
C C C C C
D D D D D D D
E E E E E E E E E
'''
n = int(input("Enter the number of rows: "))
for i in range(1, n + 1):
print(" "*(n - i), (str(chr(64 + i) + " ")) * (2 * i - 1))

'''
Pattern-38:
A
C C C
E E E E E
G G G G G G G
I I I I I I I I I
'''

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


for i in range(1, n + 1):
print(" "*(n - i), (str(chr(64 + 2 * i - 1) + " ")) * (2 * i - 1))

'''
Pattern-39:
1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
'''
n = int(input("Enter the number of rows: "))
for i in range(1, n + 1):
print(" "*(n - i), end="")
for j in range(1, 2 * i):
print(j, end=" ")
print()

'''

www.leelasoft.com Cell: 78 42 66 47 66
Leela Soft Python Patterns Madhu

Pattern-40:
1
3 2 1
5 4 3 2 1
7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
'''

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


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

'''
Pattern-41:
A
A B C
A B C D E
A B C D E F G
A B C D E F G H I
'''
n = int(input("Enter the number of rows: "))
for i in range(1, n + 1):
print(" "*(n - i), end="")
for j in range(65, 65 + 2 * i - 1):
print(chr(j), end=" ")
print()

'''
Pattern-42:
A
C B A
E D C B A
G F E D C B A
I H G F E D C B A
'''
n = int(input("Enter the number of rows: "))
for i in range(1, n + 1):
print(" "*(n - i), end="")
for j in range(65 + 2 * i - 2, 64, -1):
print(chr(j), end=" ")
print()

www.leelasoft.com Cell: 78 42 66 47 66
Leela Soft Python Patterns Madhu

'''
Pattern-43:
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
'''
n = int(input("Enter the number of rows: "))
for i in range(1, n + 1):
print(" "*(n - i), end="")
for j in range(1, i):
print(i - j, end=" ")
for k in range(0, i):
print(k, end=" ")
print()

'''
Pattern-44:
A
B A B
C B A B C
D C B A B C D
E D C B A B C D E
'''

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


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

'''
Pattern-45:
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
'''

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

www.leelasoft.com Cell: 78 42 66 47 66

You might also like