DEV Community

Saravanan Lakshmanan
Saravanan Lakshmanan

Posted on

Python Learning Series - Pattern programs

Task 1

no = 0
for row in range(6,1,-1):
    for col in range(1,row):  
        no+=1 
        print(no, end = ' ')
    print()
Enter fullscreen mode Exit fullscreen mode

Output:

1 2 3 4 5 
6 7 8 9 
10 11 12 
13 14 
15 
Enter fullscreen mode Exit fullscreen mode

Task 2

for row in range(6,1,-1):
    for col in range(1,row):
        print(chr(64+col), end = '  ')
    print() 
Enter fullscreen mode Exit fullscreen mode

Output:

A B C D E
A B C D
A B C
A B
A
Enter fullscreen mode Exit fullscreen mode

Top comments (0)