Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 82 - 2612_Digimind
P. 82

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

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

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

                          Program2.py                                               Output

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

                      Program 3: To print whole numbers from 0 to 4 using only stop value
                          Program3.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

                              uiz    Bee       Write the purpose of the range() function.

                                               _________________________________________________________________

                       80   Premium Edition-VIII

| 77 78 79 80 81 82 83 84 85 86 87 |