Page 167 - TP_Plus_v2.2_Class_8
P. 167

b. def countX(lst, X):
                         count = 0

                           for ele in lst:
                             if(ele==X):
                              count = count + 1
                             return count
                           lst = [5.24, 89, 5, 14, 5]
                           X = 5
                           print("{} has occurred {} times".format(X, countX(lst, X)))


                     Let's exPLore                                                                 21 st
                                                                                                 Century   #Media Literacy
                                                                                                  Skills
                     Surf the Internet and explore about the List in Python.




                           SDG Activity


                    Design a simple computer network to track and monitor waste production and
                    recycling in your school. Create a program that collects data from different
                    classrooms, displays yearly wastage, and suggests ways to reduce it.







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

                     1.    Count the total number of digits in the number 542892 and display it as output.
                     2.   Type your name in Python and make the first and the last letter of your name uppercase
                        and let the other letters remain lowercase.




                                                         For The Teacher


                       Demonstration of creating functions to the students.
                       Explain String in detail to the students.















                                                                                      Functions and String in Python  165
   162   163   164   165   166   167   168   169   170   171   172