Page 145 - Plus_V2.2_C8_Flipbook
P. 145

test Your skiLLs



                 1.  Tick ( ) the correct option.

                    a.  What do while loop do?

                       (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 jump statement in Python?

                       (i)  for statement                              (ii)  while statement
                       (iii)  if statement                             (iv)  break statement

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

                       (iii)  if…else statement                        (iv)  continue statement
                    d.  Which of the following statements terminates the execution of the loop?

                       (i)  if                                         (ii)  for

                       (iii)  break                                    (iv)  continue
                 2.  Write ‘T’ for true and ‘F’ for false statements.

                    a.  We cannot use range() function with for loop in Python.                        ____________

                    b.  The continue statement breaks the loops one by one.                            ____________
                    c.   To come out of the infinite loop, we can either close the program window
                       or press Ctrl + C.                                                              ____________

                    d.  A sequence is a succession of values bound together by a single name.          ____________
                    e.  The while statement is the looping statement.                                  ____________

                 3.  Fill in the blanks using the words from the help box.


                                             infinite, break, while, continue, non-zero, false

                    a.   The ____________ statement executes a set of statements repeatedly, until the logical expression
                       remains true.

                    b.   Any ____________ value in the while loop indicates an always true condition whereas zero
                       indicates ____________ condition.

                    c.  The ____________ loop never ends.
                    d.  The ____________ and ____________ are the jump statements in Python.




                                                                                                  Loops in Python  143
   140   141   142   143   144   145   146   147   148   149   150