Pattern 1:
num = 0
for row in range(5,0,-1):
for col in range(1,row+1):
print(col+num,end = ' ')
num+=row
print()
Output:
1 2 3 4 5
6 7 8 9
10 11 12
13 14
15
Pattern 2:
value = 64
for row in range(5,0,-1):
no = 1
for col in range(1,row+1):
print(chr(value+no),end = ' ')
no+=1
num+=row
print()
Output:
A B C D E
A B C D
A B C
A B
A
Pattern 3:
value = 64
for row in range(1,6):
no = 1
for col in range(1,row+1):
print(chr(value+no),end = ' ')
no+=1
num+=row
print()
Output:
A
A B
A B C
A B C D
A B C D E
Top comments (0)