Page 103 - Plus V4 with Adobe class 8
P. 103

Program 6: To demonstrate the use of while loop with else statement.













            On running the above program, we get the following output:
















                     Double Tap                                                Century   #Information Literacy
                                                                                  21 st
                                                                                 Skills

                   1.  Write the syntax of for loop.


                   2.  Write the syntax of while loop.



                   3.  Write the output of the following:
                      a.  for num in range(-10, 0, 1):

                           print(num)


                      b.  count = 0
                         while (count < 5):
                           count = count + 1
                           print("Orange Education")




                 INFINITE LOOP


            If the condition  given  in a loop never becomes false, then  the loop will  never terminate and run
            indefinitely. This type of loops is called an infinite loop.
            Example:

            while(1)
                print(“Hello”)
            Output: Hello will be printed infinite times.


                                                                                              #Loops in Python 101
   98   99   100   101   102   103   104   105   106   107   108