[go: up one dir, main page]

0% found this document useful (0 votes)
12 views5 pages

Pattern Programs Part 2

The document contains Python code for generating various patterns using loops. Patterns include right-angled triangles, number sequences, and alphabet arrangements, with each pattern demonstrated through specific code snippets. Users are prompted to enter the number of rows for each pattern, which adjusts the output accordingly.
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)
12 views5 pages

Pattern Programs Part 2

The document contains Python code for generating various patterns using loops. Patterns include right-angled triangles, number sequences, and alphabet arrangements, with each pattern demonstrated through specific code snippets. Users are prompted to enter the number of rows for each pattern, which adjusts the output accordingly.
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

'''
Squares:
Right Angled Triangle
Reverse of Right Angled Triangle
'''
'''
Pattern-15:
* * * * *
* * * *
* * *
* *
*
'''

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


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

'''
Pattern-16:
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
'''

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


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

'''
Pattern-17:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
'''

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):


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

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

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


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

'''
Pattern-19:
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):
for j in range(1, n + 2 - i):
print(chr(64 + j), end=" ")
print()

'''
Pattern-20:
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
'''

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):


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

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

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

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

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


for i in range(1, n + 1):
for j in range(1, n + 2 - i):

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

print(chr(65 + n - j), end=" ")


print()

'''
Pattern-24:
*
**
***
****
*****
'''

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


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

'''
Pattern-25:
*
* *
* * *
* * * *
* * * * *
'''

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+1):
print("*",end=" ")
print()

'''
Pattern-26:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
'''

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


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

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

'''
Pattern-27:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
'''
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 + 1):
print(j, end=" ")
print()

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

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


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

'''
Pattern-29:
A
A B
A B C
A B C D
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+1):
print(chr(64+j),end=" ")
print()

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

You might also like