Page 50 - Modular v1.1 Pyhton
P. 50

Exercise


                  A.  Tick ( ) the correct option.

                      1.   What while loop do?
                          a.    Repeat a chunk of code a given number of times

                          b.    Repeat a chunk of code until a condition is true
                          c.    Repeat a chunk of code until a condition is false

                          d.    Repeat a chunk of code indefinitely
                      2.   Which of the following is a looping statement in Python?
                          a.    for statement                            b.   while statement
                          c.    if statement                             d.   break statement
                      3.   Which of the following statements allow to repeat a task for a fixed number of times?
                          a.    for statement                            b.   while statement

                          c.    if…else statement                        d.   continue statement
                      4.   Which of the following statements terminates the execution of the loop?
                          a.    if                                       b.   for
                          c.    break                                    d.   continue

                  B.  Write 'T' for true and 'F' for false statements.

                      1.   The range( ) function is used in the for loop to iterate over the numbers.   ……………………
                      2.   The continue statement breaks the loops one by one.                          ……………………
                      3.    To come out of the infinite loop, we can either close the program window
                           or press Ctrl + C.                                                           ……………………
                      4.   A sequence is a succession of values bound together by a single name.        ……………………
                      5.   The while statement is the looping statement.                                ……………………

                  C.  Fill in the blanks using the words given below.



                                                        infinite, break, while, continue

                      1.     The …………………… statement executes a set of statements repeatedly, until the logical expression
                           remains true.
                      2.   The …………………… loop never ends.

                      3.   The …………………… and …………………… are the jump statements in Python.
                  D.  Short answer type questions.

                      1.   What is looping?
                      2.   Write the syntax of the for loop.

                      3.   What is the use of Jump statement?





                   48     Touchpad MODULAR (Version 1.0)
   45   46   47   48   49   50   51   52   53   54   55