Python : Looping Statement Test 3

 

Looping Statement Test 3

Q1. Convert the following while loop into for loop and also find the output.

S. No.

CODE

OUTPUT

a.

x=5

while(x<15):

  print(x**2)

  x+=3

 

 

b.

a=7

b=5

while(a<9):

  print(a+b)

  a+=1

 

 

c.

b=5

while(b<9):

  print("H")

  b+=1

 

 

d.

b=15

while(b>9):

  print("Hello")

  b=b-2

 

 

e.

x=15

while(x==15):

  print("Hello")

  x=x-3

 

 

 

2 comments:

  1. Indeed, useful blog.
    The worksheets has variety of questions

    ReplyDelete
    Replies
    1. Thankyou so much for your appreciation. Subscribe and Share with your friends and students.

      Delete

Most Recently Published

File Handling Test 6

 File Handling Test 6 Q1 . Do we need to use the close() function when we use 'with' statement to open a file? Q2. Which mode you wi...

CS - IP Assignment/Worksheet