0% found this document useful (0 votes)
5 views4 pages

Python For Loop Patterns Explained

The document contains multiple examples of nested for loops in Python. Each example demonstrates different patterns of output, such as printing numbers, symbols, and cubes. The loops iterate through specified ranges to produce formatted results in the console.

Uploaded by

r.verma8850
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)
5 views4 pages

Python For Loop Patterns Explained

The document contains multiple examples of nested for loops in Python. Each example demonstrates different patterns of output, such as printing numbers, symbols, and cubes. The loops iterate through specified ranges to produce formatted results in the console.

Uploaded by

r.verma8850
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

FOR LOOP

for i in range(1,5):

print('1' * i)

for i in range(1,5):

print()

for j in range(i):

print(i,end=' ')

for i in range(1,5):

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

print(j,end=' ')

print()
for i in range(1,5):

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

print(i*j,end=' ')

print()

for i in range(1,5):

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

print(i*i,end=' ')

print()

for i in range(1,5):

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

print(j*j*j,end=' ')

print()
num=1

for i in range(1,5):

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

print(num,end='')

num=num+1

print()

for i in range(1,6):

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

if i % 2==0:

print('#',end='')

else:

print('*',end='')

print()

num=1

for i in range(1,5):

for j in range(1,5):

if i>=j:

print(num,end='')

num=num+1

else:
print('*',end='')

print()

You might also like