Page 104 - Dig_CodeAI_V2.1_Class_8
P. 104
Computational Thinking
Information Literacy
Write the output of the following programs:
1. def f(x):
y = x**x
return y
print ("testing...")
print ("passing the value 4")
z = f(2)
print ("the function returns", z)
2. def power(x, n):
result = 1
for i in range (n):
result *=x
return result
a = int (input ("Enter number"))
b = int (input ("Raise to power"))
pw = power (a, b)
print(a, "raise to power", b, "is", pw)
Experiential Learning
Competency-based/Application-based question Information Literacy
Kazim wants to create a program in which he needs to multiply two numbers using
functions. Which type of function will be suitable for Kazim?
(i) built-in function (ii) user-defined function
Experiential Learning
code TASK Information Literacy
Write a program using functions to:
1. check whether the input number is even or odd.
2. print a string 'orange' by calling a function.
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.
102 DigiCode AI (Ver. 2.1)-VIII

