0% found this document useful (0 votes)
55 views3 pages

Nested Loops in Python Examples

Uploaded by

need.adhikari007
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)
55 views3 pages

Nested Loops in Python Examples

Uploaded by

need.adhikari007
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

# WAP to print

55555

4444

333

22

for i in range (5,0,-1):

print()

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

print(i,end=" ")

# WAP to print

23

456

7 8 9 10

a=1

for i in range (1,5):

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

print(a,end=" ")

a=a+1

print()

# WAP to print all the prime numbers between 10 and 100

for i in range(10,101):

p=0

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

if i%j==0:

p=p+1

if p==2:

print(i)
# Nested whiles

i=0

while i<3:

j=0

while j<4:

print ("Hello ",j)

j=j+1

i=i+1

# WAP to print all the Armstrong numbers between 100 and 1000

#371= 3*3*3+7*7*7+1*1*1=27+343+1=371

for n in range (10,1001):

s=0

m=n

while n>0:

r=n%10

s=s+(r*r*r)

n=n//10

if m==s:

print(m)

# WAP to print

***

*****

*******

*********

***********
# WAP to print

***

*****

*******

*********

***********

*********

*******

*****

***

You might also like