Page 144 - Plus_V2.2_C8_Flipbook
P. 144

Factopedia                                    Let’s BaCk-uP



                                                        Looping  statements  are very useful  and  necessary  for
                                                      developing applications.

                                                        Python provides two looping statements—for and while.
                                                        The for statement executes a simple or compound statement
                                                      for a fixed number of times.
                                                       The range() function is an in-built function of Python.

                     Python is the only                 A sequence is a succession  of values bound  together  by  a
                    language which uses               single name.
                    else statement with                 The while statement executes a set of statements repeatedly,
                         the loops.
                                                      until the logical expression evaluates to true.
                                                        To come  out  of the  infinite  loop,  we can either close  the
                                                      program window or press Ctrl + C.
                                                        The else  block  is  executed  when the  condition  given  in  the
                                                      while statement becomes false.

                                                        The break is a keyword in Python which is used for bringing
                                                      the program control out of the loop.
                        Some of the
                      companies like                    When a continue  statement  is encountered  inside  a loop,
                    NASA     , Netflix  ,             control of the program jumps to the beginning of the loop for
                        Google     ,                  next iteration, skipping the execution of rest of the statements
                        Amazon  ,                     of the loop.
                       YouTube      ,
                         Spotify  ,
                     Dropbox     , etc.
                    use (or have used)
                      Python for their
                     products/services.















                   Python does not have
                       do-while loop.





                  142   Premium Edition-VIII
   139   140   141   142   143   144   145   146   147   148   149