Page 120 - 2622_Delhi Police Public School_C-8
P. 120

Program 9: To print first 12 whole numbers except 8.

                   Program9.py
                File  Edit  Format   Run   Options   Window    Help


                #Program to show the use of the continue statement
                for number in range(0, 12):
                    if(number == 8):
                        continue
                    print('Number is:', number)
                print('Out of loop')





              On executing the above program, you will get the following output:

                   Output

                Number is: 0
                Number is: 1
                Number is: 2
                Number is: 3
                Number is: 4
                Number is: 5
                Number is: 6
                Number is: 7
                Number is: 9
                Number is: 10
                Number is: 11
                Out of loop





                       Topic Flashback                                                    21 st  Century
                                                                                              Skills  #Critical Thinking

                     What will be the output of the given Python code?
                     a.   i = 0
                         while (i == 0): print("Hello Computer Science")

                     b.   i = 1
                         while (i<=5):
                           print("i=",i)
                           i+=1
                         print("Done")







                        Premium Edition-VIII
                118
   115   116   117   118   119   120   121   122   123   124   125