Page 71 - Code & Click - 8
P. 71

The Continue Statement
            The Continue statement causes the interpreter to skip the remaining statements in the body of the
            loop and move to the start of the loop block. It transfers the execution control to the test expression
            in the loop statement.
                                                                                                 Experiential Learning
              Lab Activity 9

             To display all numbers from 1 to 10, except multiples of 3, using While loop.
             1. Type the code as shown in the image in the Python Editor.
















             2. Press the F5 key to execute the code. Sample output of the program is given.


             P
             Post-Processingost-Processing
               Iterative statements, or loops, are statements that are executed a specified number of times
                  or until a specified condition is True.
                The  For  loop  is  used  when  the  number  of  times  the  loop  is  to  be  executed  is  known
                  beforehand.
                The Range( ) function is used to specify a range of values which are assigned in sequence to
                  the counter variable in the For loop.

                The While loop in Python is used to execute a set of instructions repeatedly until a certain
                  condition is satisfied.
                Jump statements let the execution control jump to a specific position in the program.



                                                        Info Retention

            A.   Select the correct option for each of the following statements.
                1.  Loops belong to which category of statements?
                    (a)  Conditional        (b)  Selection            (c)  Iterative          (d)  Sequential

                2.  The variable used in the test expression of a loop is called the ______.
                    (a)  Condition variable  (b)  Control variable    (c)  Test variable      (d)  loop variable
                3.  The jump statement in Python is
                    (a)  Jump               (b)  GoTo                 (c)  Break              (d)  End

            B.  Fill in the blanks with the correct answer.

                1.  _________ and _________ are the two types of loops in Python.


                                                                                                                 69
   66   67   68   69   70   71   72   73   74   75   76