Page 128 - trackpad v5.1 class 8 flipbook
P. 128
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
#Critical thinking
21 st
{C ding z ne}
[]
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.
126 Pro (V5.1)-VIII

