A. Is it possible to nest the while loop within for loops? B. When is the break statement used? C. When is the continue statement used? D. Convert the following for loop into while loop. for i in...

A. Is it possible to nest the while loop within for loops?

B. When is the break statement used?


C. When is the continue statement used?


D. Convert the following for loop into while loop.


for i in range(50,0,-2):



print(i,end=’ ‘)


E. Answer the following questions.


a. How many times will the following loop execute and what will be its output for both the programs,


a and b?


sum=0


for i in range(20,0,-2):


sum=sum+i


print(i)


if i==14:


continue


print (sum)


(a)


sum=0


for i in range(20,0,-2):


sum=sum+i


print(i)


if i==14:


break


print(sum)


(b)




F. Convert the following while loop into for loop


i=0


s=0


while i


if i%7==0:


s = s+i


i = i+7


print(s)





May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here