Q. Find the output of the following program segments:


(i)

a = 110

while a > 100:

      print(a)

      a -= 2


(ii)

for i in range(20,30,2):

       print(i)


(iii)

country = 'INDIA'

for i in country:

       print (i)


(iv)

i = 0; sum = 0

while i < 9:

     if i % 4 == 0:

              sum = sum + i

     i = i + 2

     print (sum)


(v)

for x in range(1,4):

      for y in range(2,5):

              if x * y > 10:

                     break

              print (x * y)

             

(vi)

var = 7

while var > 0:

      print ('Current variable value: ', var)

      var = var -1

      if var == 3:

             break

      else:

             if var == 6:

                    var = var -1

                    continue

       print ("Good bye!")


Answer :-

I =
110
108
106
104
102

II =
20
22
24
26
28

III =
I
N
D
I
A

IV =
0
0
4
4
12

V=
2
3
4
4
6
8
6
9


VI =
Current variable value:  7
Current variable value:  5
Good bye!
Current variable value:  4


Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post