Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 152 - 2632_CodeMind
P. 152

    test Your skiLLs

                     1.  Tick ( ) the correct option.

                        a.  What does 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.  The range() function is used in the ____________ to iterate over the numbers.

                           (i)  for loop                                   (ii)  while loop
                           (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 loop                                   (ii)  while loop

                           (iii)  break 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.  Fill in the blanks using the words given below:

                                                   infinite, break, while, continue, non-zero

                        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 False condition.
                        c.  The ____________ loop never ends.

                        d.  The ____________ and ____________ are the jump statements in Python.

                     3.  Write ‘T’ for true and ‘F’ for false statements.

                        a.  We can use do-while 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.                                  ____________

                                                                                                      Loops in Python  151

| 147 148 149 150 151 152 153 154 155 156 157 |