9610388-XII_CS_Worksheet 2_FUNCTIONS (2)
9610388-XII_CS_Worksheet 2_FUNCTIONS (2)
Worksheet, 2025-26
Class: XII Comp. Sci. Department: Computer Science Complete it by 21.04.25
def Add(X,Y):
Z = X+Y
return Z
#statement to call the above function
print(“Total =”,C)
7 Which Line Number Code will never execute?
def Check(num): #Line 1 if
num%2==0: #Line 2
print("Hello") #Line 3
return True #Line 4
print("Bye") #Line 5
else: #Line 6
return False #Line 7
C=Check(20)
print(C)
1| 1 2 - 0 4 - 2 0 2 5 / P R E P A R E D B Y : M r s . K H U S H B U J O S H I
8 What will be the output of following code?
def Cube(n):
print(n*n*n)
Cube(n) # n is 10 here
print(Cube(n))
9 What will be the output?
def add(i):
if(i*3%2==0):
i*=i
else:
i*=4
return i
a=add(10)
print(a)
10 What will be the output?
def div5(n):
if n%5==0:
return n*5
else:
return n+5
def output(m=5):
for i in range(0,m):
print(div5(i),’@’,end=” “)
print(‘\n’)
output(7)
output()
output(3)
12 What will be the output?
def func(b):
global x
print(‘Global x=’, x)
2| 1 2 - 0 4 - 2 0 2 5 / P R E P A R E D B Y : M r s . K H U S H B U J O S H I
y=x+b
x=7
z=x–b
print(‘Local x = ‘,x)
print(‘y = ‘,y)
print(‘z = ‘,z)
x=5
func(10)
13. What will be the output?
def func(x,y=100):
temp = x + y
x += temp
if(y!=200):
print(temp,x,x)
a=20
b=10
func(b)
print(a,b)
func(a,b)
print(a,b)
14 Write a function, Words(S), that takes a string as an argument and returns a list containing words of the
string that has consonants.
15 Write the definition of a function Reverse (x) in Python, to display the elements in reverse order such
that each
displayed element is the twice of the original element (element *2) of the List x in the following manner:
Example :
If List x contains 7 integers is as follows:
4 8 7 5 6 2 10
After executing the function, the array content should be displayed as follows:
20 4 12 10 14 16 8
16 Write a user-defined function find-name (name), where name is an argument in Python to capital of the
country from a dictionary country-name on the basis of the country name, where name is the key.
3| 1 2 - 0 4 - 2 0 2 5 / P R E P A R E D B Y : M r s . K H U S H B U J O S H I