Page 149 - TP_Prime_V2.2_Class8
P. 149

Let's Revisit

                 •  The statements that repeatedly execute a set of statements as long as the provided
                   condition is evaluates to true are called iterative statements.

                 •  The range() function generates a sequence of numbers.
                 •  A loop which never ends is called an infinite loop.

                 •  The else statement can be used with loops but it is not mandatory.



                                                    Mind Drill                                                              LOOPS IN PYTHON





                    Rapid Fire



                 1.  Tick () the correct option.
                                                                                                                          147
                     a.  Which of the following statements is correct with respect to the while loop?
                        (i)  Repeat a chunk of code a given number of times

                        (ii)  Repeat a chunk of code until a condition is true

                        (iii)  Repeat a chunk of code until a condition is false

                        (iv)  Repeat a chunk of code indefinitely

                     b.  Which of the following is a looping statement in Python?

                        (i)  for statement                                    (ii)  continue statement

                        (iii)  if statement                                   (iv)  break statement

                     c.  Which of the following statement allows to repeat a task for a fixed number of times?
                        (i)  for statement                                    (ii)   continue statement

                        (iii)  if…else statement                              (iv)  continue statement




                   Evaluation Time


                 1.  Fill in the blanks using the hints given below:
                                              Infinite,   While,   For,   In,   Else

                     a.   The two types of iterative statements are ________ and ________.

                     b.    The two types of membership operators are ________ and ________.
                     c.  The _____________ statement is executed only after the loop condition became false.

                     d.   A loop that never ends is called an _____________ loop.
   144   145   146   147   148   149   150   151   152   153   154