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

Baisc Nested Loop

The document contains various examples of nested loops in Python, demonstrating how to print characters and numbers in different formats. It includes both 'for' and 'while' loop structures, producing outputs such as letters from A to Z and numerical sequences. The examples illustrate different ways to format output using characters and symbols.

Uploaded by

sushantsaini3333
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)
6 views5 pages

Baisc Nested Loop

The document contains various examples of nested loops in Python, demonstrating how to print characters and numbers in different formats. It includes both 'for' and 'while' loop structures, producing outputs such as letters from A to Z and numerical sequences. The examples illustrate different ways to format output using characters and symbols.

Uploaded by

sushantsaini3333
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

baisc-nested-loop

February 17, 2025

[46]: for i in range(65,69):


for j in range(65,70):
print(chr(j),end=" ")
print()

A B C D E
A B C D E
A B C D E
A B C D E

[49]: i = 0
while i < 4:
j = 0
while j < 5:
print(chr(65 + j), end=" ")
j += 1
print()
i += 1

A B C D E
A B C D E
A B C D E
A B C D E

[ ]:

[42]:

[7]: for i in range(65,68):


for j in range(65,69):
print((j),end=" | ")
print()

65 | 66 | 67 | 68 |
65 | 66 | 67 | 68 |
65 | 66 | 67 | 68 |

[ ]:

1
[ ]:

[6]: i=0
while i<3:
j=0
while j<4:
print((65+j), end=" | ")
j +=1
print()
i +=1

65 | 66 | 67 | 68 |
65 | 66 | 67 | 68 |
65 | 66 | 67 | 68 |

[ ]:

[22]: for i in range(2,6):


for j in range(1,i,):
print(j,end=" | ")
print()

1 |
1 | 2 |
1 | 2 | 3 |
1 | 2 | 3 | 4 |

[ ]:

[24]: for i in range(1,5):


for j in range(5,i,-1):
print(j,end=" | ")
print()

5 | 4 | 3 | 2 |
5 | 4 | 3 |
5 | 4 |
5 |

[ ]:

[ ]:

[ ]:

[ ]:

2
[27]: for i in range(1,3):
for j in range(1,4):
print(j,end=" ")
print()

1 2 3
1 2 3

[ ]:

[39]: for i in range(65,75):


for j in range(65,91):
print(chr(j), end=" | ")
print()

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
U | V | W | X | Y | Z |

[ ]:

[59]: for i in range(64,91):


for j in range(90,i,-1):
print(chr(j), end="|")
print()

Z|Y|X|W|V|U|T|S|R|Q|P|O|N|M|L|K|J|I|H|G|F|E|D|C|B|A|
Z|Y|X|W|V|U|T|S|R|Q|P|O|N|M|L|K|J|I|H|G|F|E|D|C|B|
Z|Y|X|W|V|U|T|S|R|Q|P|O|N|M|L|K|J|I|H|G|F|E|D|C|
Z|Y|X|W|V|U|T|S|R|Q|P|O|N|M|L|K|J|I|H|G|F|E|D|
Z|Y|X|W|V|U|T|S|R|Q|P|O|N|M|L|K|J|I|H|G|F|E|

3
Z|Y|X|W|V|U|T|S|R|Q|P|O|N|M|L|K|J|I|H|G|F|
Z|Y|X|W|V|U|T|S|R|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