Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 108 - 2612_Digimind
P. 108

    # Using the function

                               electricity_usage = 300  # kWh

                               gas_usage = 50  # m3
                               water_usage = 2000  # liters

                                total_footprint = carbon_footprint(electricity_usage, gas_usage, water_
                               usage)
                               print(f"Total carbon footprint: {total_footprint} kg CO2")

                                Explain how this function can be used to promote sustainable practices.
                                  In the list given below, use functions to edit it and only display numbers that are divisible by 4. If
                               there is a number greater than 100, then stop the loop iteration.

                               list = [8, 13, 16, 24, 35, 50, 60, 72, 75, 100, 120, 160]
                                  Write a program that counts the total number of digits in the number 542892 and displays it as
                               output.

                               COding Zone       COding Zone    {}      =     COding Zone                COding Zone
                                     {C ding z ne}
                                                                                             21 st
                                                                                                #Critical thinking
                                                                                                                  []
                                                                                           Century
                                                                                                #Technology Literacy
                                                                                            Skills
                                                                               </>
                          Find errors in the code of the programs given below, correct them and write the output.
                          (a)  def greet()                            (b)  def add(a, b)
                                  print("Hello")                          return a + b
                              greet();                                    print[add(2, 3))
                          (c)  s = "Hello                             (d)  lst = [1, 2, 3]
                              print(S)                                    lst.append[4]
                                                                          Print(lst)
                          (e)  def subtract(a, b):

                              return a - b
                              print(subtract(5, 3)

                            CAREER HERE
                      People who are experts in Python may pursue their career as a software developer.

                         FOR THE TEACHER
                        1.  Demonstration of creating functions to the students.
                        2.  Explain List and String in detail to the students.

                      106   Premium Edition-VIII

| 103 104 105 106 107 108 109 110 111 112 113 |