Page 115 - modular4.0
P. 115

Chapter Profile
                     2.  for i in range(3):

                             print(i)
                         else:
                             print("Loop finished")
                                                                                                 21 st   #Critical Thinking
                                                                                              Century
                 G.  Competency-based/Application-based questions.                              Skills  #Technology Literacy

                     1.   Ajay is creating a program for a number guessing activity in class. His teacher wants
                         the program to keep asking users for a positive number and end only when a number
                         greater than 100 is entered. Help him write a Python program using a while loop to
                         achieve this.
                     2.   You are designing a game where players earn points by selecting numbers that are not divisible by
                         3. Create a Python program using a for loop and the continue statement to print all numbers from 1
                         to 10, excluding those divisible by 3.


                           SDG Activity


                    Use a while loop to create a program that encourages healthy habits by counting
                    daily steps. Write a program where students enter their daily steps. The while loop
                    will continue prompting them to enter steps until a goal of 10,000 steps is reached.
                    Use a continue statement if the student enters a value below a healthy target (e.g.,
                    less than 100 steps).




                                                                                                 21 st   #Critical Thinking
                                                                                              Century   #Technology Literacy
                 In the Lab                                                                     Skills

                   Write a program to:
                       calculate the sum of the first N natural numbers using a for loop.

                       prints the multiplication table of a number entered by the user using a while loop.
                        runs an infinite loop, asking the user to enter a number, and break the loop if the number is
                       negative.
                       prints all odd numbers from 1 to 10 using a for loop and the continue statement.
                       calculate the factorial of a number entered by the user using a while loop.





                   Teacher's Corner

                      Discuss about all the looping statements of Python with the students.
                      Go through all the topics covered in this chapter.














                                                                                                     Loops in Python  113
   110   111   112   113   114   115   116   117   118   119   120