Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 107 - 2612_Digimind
P. 107

    e.  s = "hello"                                        f. def multiply(x, y=2):

                            s = s.capitalize()                                         return x * y
                            print(s)                                               print(multiply(3))
                            ______________________                                 ______________________

                                                                                                  21 st   #Critical thinking
                     7.  Competency-based/Application-based questions.                          Century   #Technology Literacy
                                                                                                 Skills
                        a.   Yash made a list in Python and forgot to add a couple of elements to it. Which function can he use
                            to add these elements?
                        b.   Mira wants to receive a string from the user and change the first letter of the string to uppercase
                            before saving it to a variable. How can she achieve this in Python?
                        c.   Aadya created multiple strings in Python. She now wishes to join the strings to form a single string.
                            Is this possible? How can she do this?

                               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.

                                                                                                      21 st   #Critical thinking
                        LAB ACTIVITY                                                               Century   #Technology Literacy
                                                                                                     Skills

                         Visit your computer lab and perform the following actions:

                              Write the following Python function that calculates the carbon footprint of a household based on
                           electricity usage, gas usage and water usage. The function takes in these parameters and returns
                           the total carbon footprint.

                           def carbon_footprint(electricity_kwh, gas_m3, water_liters):

                                # Approximate  conversion  factors (values are for illustration
                           purposes)

                               carbon_per_kwh = 0.233  # kg CO2 per kWh

                               carbon_per_m3_gas = 2.20462  # kg CO2 per cubic meter
                               carbon_per_liter_water = 0.001  # kg CO2 per liter

                                total_carbon = (electricity_kwh * carbon_per_kwh) + (gas_m3 * carbon_
                           per_m3_gas) + (water_liters * carbon_per_liter_water)

                               return total_carbon

                                                                                       Functions, String and List in Python  105

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