Page 154 - TP_Plus_v2.2_Class_8
P. 154

b.  start = 1
                             end = 10
                              for number in range(start, end + 1):
                                 square = number ** 2
                                  print("The square of", number, "is", square)
                           c. i = 2
                             while True:
                                 if i%3 == 0:
                                     break
                                 print(i)
                                 i += 2
                           d. i = 0
                             while i < 5:
                                 print(i)
                                 i += 1
                                 if i == 3:
                                     break
                             else:
                                 print(0)
                           e.  numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
                             for number in numbers:
                                 if number % 2 == 0:
                                      print(number, "is even")
                                 else:
                                      print(number, "is odd")
                                                                                                21 st
                      Let's exPLore                                                          Century   #Media Literacy
                                                                                               Skills
                  .   Surf the Internet and explore why Python is more famous than the other languages.



                      teCh PraCtiCe                                                      21 st
                                                                                       Century   #Critical Thinking
                                                                                        Skills
                      Write a program to:

                      1.   determine whether a given number is an Armstrong number or not.
                      2.  use the for loop to print the numbers 8, 11, 14, 17, 20, . . . , 83, 86, 89.
                      3.  use the for loop to print the numbers 100, 98, 96, . . . , 4, 2.

                      4.  print 1 to 100 numbers using while loop.
                      5.   find out the sum of numbers within the range 1 to 100 using while loop.




                                                          For The Teacher

                         Discuss about all the iterative statements of Python with the students.

                         Go through all the topics covered in this chapter.


                  152   Plus (Ver. 2.2)-VIII
   149   150   151   152   153   154   155   156   157   158   159