Page 99 - Plus V4 with Adobe class 8
P. 99

Take Off                                                           Century   #Critical Thinking
                                                                                               21 st
                                                                                              Skills
                 State whether these statements are true or false.
                 1.  Python does not support conditional statements.

                 2.  We can use if statement inside other if statement.

                 3.  We can check multiple conditions in Python.





            Sometimes, you need to repeat a task multiple time or you may need to repeat the task either a certain
            number of times or until a condition is satisfied. In Python, the statements that are used to repeat a
            set of instructions are called iterative or looping statements. Looping statements are very useful and
            necessary for developing applications.

            Python provides two types of looping statements—for and while. The for statement is used to repeat
            an instruction or a set of instructions a fixed number of times. Whereas, the while statement is used
            to repeat a set of instructions until a condition evaluates to true. Let’s discuss these constructs in brief.


                 THE FOR STATEMENT

            The for statement executes a simple or compound statement for a fixed number of times. The syntax
            of the for statement is given below:

            for <variable> in <iterator>:
                   Statements

                                                                   for each
                                                                    item in
                                                                   sequence

                                                             Last item    True
                                                             reached?


                                                                  False

                                                            Body of for



                                                                    Exit loop


             Program 1: To print all the days of a week.














                                                                                              #Loops in Python  97
   94   95   96   97   98   99   100   101   102   103   104