0% found this document useful (0 votes)
51 views3 pages

9610388-XII_CS_Worksheet 2_FUNCTIONS (2)

This worksheet for Class XII Computer Science covers various topics related to functions in Python, including defining, calling functions, and understanding code execution. It includes multiple questions and coding exercises that require students to write and analyze function definitions and their outputs. The worksheet must be completed by April 21, 2025.

Uploaded by

jenishk2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views3 pages

9610388-XII_CS_Worksheet 2_FUNCTIONS (2)

This worksheet for Class XII Computer Science covers various topics related to functions in Python, including defining, calling functions, and understanding code execution. It includes multiple questions and coding exercises that require students to write and analyze function definitions and their outputs. The worksheet must be completed by April 21, 2025.

Uploaded by

jenishk2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

INDIAN SCHOOL AL WADI AL KABIR

Worksheet, 2025-26
Class: XII Comp. Sci. Department: Computer Science Complete it by 21.04.25

Worksheet No: 2 Topic: Functions Note: To be solved in


the notebook

1 Function name must be followed by

2 keyword is used to define a function

3 Function will perform its action only when it is

4 Write statement to call the function.


def Add():
X = 10 + 20
print(X)
#statement to call the above function
5 Write statement to call the function.
def Add(X,Y):
Z = X+Y
print(Z)
#statement to call the above function
6 Write statement to call the function.

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 fun1(x, y):


x=x+y
y=x–y
x=x–y
print(‘a=’,x)
print(‘b=’,y)
a=5
b=3
fun1(a,b)
11 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

You might also like