Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 151 - 2632_CodeMind
P. 151

    Factopedia                           What will be the output of the given Python code?
                                                            Let’s CatCh uP

                                                       i = 0

                                                       while (i == 0): print(“Hello Touchpad”)
                                                       ________________________________________________________

                                                                                                   21 st
                           Python is the only         Let’s PraCtiCe                             Century   #Technology Literacy
                         language which uses                                                      Skills
                          else statement with          Write a program in Python to find whether the given number is
                               the loops.              prime or not.
                                                       ______________________________________________________
                                                       ______________________________________________________

                                                                Let’s BaCk-uP

                             Some of the                    Looping  statements  are very useful  and  necessary  for
                            companies like                developing applications.
                         NASA      , Netflix  ,             Python provides two types of looping statements—for and while.
                              Google    ,                   The for statement executes a simple or compound statement
                             Amazon  ,                    for a fixed number of times.
                             YouTube     ,                 The range() function is an in-built function of Python.
                              Spotify  ,                    A sequence is a succession  of values bound  together  by  a
                           Dropbox     , etc.             single name.
                          use (or have used)                The while statement executes a set of statements repeatedly,
                           Python for their               until the logical expression evaluates to true.
                          products/services.                The else  block  is  executed  when the  condition  given  in  the
                                                          while statement becomes false.

                                                            To come  out  of the  infinite  loop,  we can either close  the
                                                          program window or press Ctrl + C.
                                                            The break is a keyword in Python which is used for bringing
                                                          the program control out of the loop.
                                                            When a continue  statement  is encountered  inside  a loop,
                                                          control of the program jumps to the beginning of the loop for
                         Python does not have             next iteration, skipping the execution of rest of the statements
                            do-while loop.                of the loop.

                      150   Premium Edition-VIII

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