Page 100 - TrackpadV5.1_class8
P. 100

Pragram 5: To print odd numbers till 10 using start, stop and step values of a range function

                      Program5.py                                               Output
                   File  Edit  Format   Run   Options  Window    Help         1
                                                                              3
                   for i in range (1,10,2):
                                                                              5
                       print(i)
                                                                              7
                                                                              9




                  Program 6: To print a selected range of numbers with start and stop values.

                      Program6.py                                               Output
                   File  Edit  Format   Run   Options  Window    Help         3
                                                                              4
                   for i in range (3,7):
                                                                              5
                       print(i)
                                                                              6



                  Program 7: To print whole numbers from 0 to 4 using only stop value

                      Program7.py
                   File  Edit  Format    Run   Options   Window    Help

                    for i in range (5):
                        print(i)




                  On running the above program, we get the following output:

                      Output
                   0
                   1
                   2
                   3
                   4




                  THE while LOOP
                  The while loop repeats a block of statements while a given condition is true. In this looping construct,

                  first, the condition is checked and if it is true, the control will move inside the loop and execute the
                  statements until the condition becomes false. If the initial condition is false, then the control will
                  not enter the loop block. The syntax of while loop is as follows:
                  while(condition):

                      statement(s)
                      increment/decrement



                   98   Pro (V5.1)-VIII
   95   96   97   98   99   100   101   102   103   104   105