Page 122 - 2611_SmartGPT Pro V(5.0) C-7
P. 122

Output

                   Odd number: 1
                   Odd number: 3                                                                To select all text:
                                                                                             Short key
                   Odd number: 5
                   Odd number: 7
                   Odd number: 9                                                                     Ctrl +   A
                   Out of for loop








                         Write Python code to illustrate jump statements like break, continue and pass.





                            SOME MORE PROGRAMS


                  Program 16. To find the average of the first 10 natural numbers.

                      Program16.py
                   File  Edit  Format   Run    Options   Window    Help

                   total = 0
                   for i in range(1, 11):
                       total += i
                   average = total / 10
                   print("Average of first 10 natural numbers is:", average)



                      Output

                   Average of first 10 natural numbers is: 5.5





                  Program 17. To know the amount of discount based on how much money you spent.

                                              Amount spent                   Discount%

                                              `5000 or more                    20% off


                                              `3000 to `4999                   10% off
                                              `1000 to `2999                   5% off


                                             Less than `1000                No discount






                  120   Computer Science (V5.0)-VII
   117   118   119   120   121   122   123   124   125   126   127