Page 127 - trackpad v5.1 class 8 flipbook
P. 127
21 st #Critical thinking
Century
7. Competency-based/Application-based questions. Skills #Technology Literacy
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
# Using the function
electricity_usage = 300 # kWh
gas_usage = 50 # m3
water_usage = 2000 # liters
Functions, String and List in Python 125

