Computer Science

Write programs using nested loops to produce the following patterns:

0
2 2
4 4 4
6 6 6 6
8 8 8 8 8

Python

Python Control Flow

28 Likes

Answer

for i in range(0, 10, 2):
    for j in range(0, i + 1, 2) :
        print(i, end = ' ')
    print()

Output

0 
2 2 
4 4 4
6 6 6 6
8 8 8 8 8

Answered By

14 Likes


Related Questions