Page 62 - tp_Modula_v2.0
P. 62
2. Write any two features of functions.
3. Write any three advantages of functions.
E. Long answer type questions.
1. Write the components of a function.
2. How can we call a function in Python? Explain using an example.
3. What are the different types of functions? Explain in detail.
4. What are the different steps to create a function? Explain in detail.
Critical Thinking
F. What will be the output of the following codes?
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)
In the lab Subject Enrichment
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.
Teacher's Corner
1. Demonstration of creating functions to the students.
2. Discuss different types of functions with the students.
60 Touchpad MODULAR (Version 2.0)

