Page 89 - ThinkGPT_V2.1_C8_Flipbook
P. 89

On running the above program, you will get the following output:
 Imagine you possess the power of the jump statement, allowing you to leap to any
 part of the universe. Where would you jump to, and what quests or missions would
 you undertake in each dimension?



 Program: To print a pattern using for loop.
 *
 **
 ***
 ****
 *****
 ******
 *******
 ********
 *********


                 The while Loop

                 The while loop executes a set of statements repeatedly, until the logical expression evaluates to
                 false. When the condition becomes false, the control comes out of the loop. The syntax of while
                 statement is given below:
 On running the above program, you will get the following output:  while (test expression):
                        Statements
                        increment/decrement expression
                 Program: To print first 5 natural numbers using while loop.













                 On running the above program, you will get the following output:




 Program: To print multiplication table of number taken as input from user.

















                                                                                Looping Statements in Python  87
   84   85   86   87   88   89   90   91   92   93   94