Page 143 - Touchpad_Plus_V3.2_Class 8
P. 143

You will get the following output:


                                                                Output

                  3
                  33
                  333
                  3333
                  33333
                  333333
                  3333333
                  33333333
                  333333333







                                    "Imagine, you possess the power of 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 10: To add first five natural numbers.


                                                            Program10.py
                   File  Edit  Format  Run    Options   Window    Help


                  #Program to add first five natural numbers

                  sum = 0
                  a = 1
                  while (a <= 5):
                      sum += a
                      a += 1
                  print('The sum of first five natural number is', sum)




                 You will get the following output:
                                                                Output

                  The sum of first five natural number is 15












                                                                                               Loops in Python       141
   138   139   140   141   142   143   144   145   146   147   148