0% found this document useful (0 votes)
14 views2 pages

12 CS WorkSheet 02 Apr24

Uploaded by

damianwayne69420
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)
14 views2 pages

12 CS WorkSheet 02 Apr24

Uploaded by

damianwayne69420
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/ 2

12 COMPTER SCIENCE WORKSHEET

TOPIC: PYHTON REVISION TOUR & USER DEFINED FUNCTION


________________________________________________________________________________________
1. Which of the following is not true for a function in Python?

a) It is a program module
b) It is a reusable piece of a program
c) You cannot create your own function
d) All of the above

2. Which of the following is the most suitable for the return statement?

a) It is the last statement of the function


b) No statement can be used after return
c) It may return multiple values to the caller
d) All of the above

3. Which of the following statements holds true for Python function?

a) It executes only when it is called


b) It always returns a value
c) It does not support nested function
d) None of the above

4. What is the default return value when a function does not return any value explicitly?

a) null b) void c) empty d) None of these

5. Find the output of the following snippets:


def Case_Converter (s):
p = len(str)
s=””
for i in range (0,p):
chr = s[i]
if (chr>=’a’ and chr<=’z’):
chr = chr.upper()
s = s + chr
elif (chr>=’A’ and chr<=’Z’):
chr = chr.lower()
s = s + chr
else:
s = s + chr
print (“The new string: ”, s)
s = “Python for class 12”
Case_Converter (s)

6. Find the output of the following snippets:


def Myreference (MyList):
MyList[2] = 50
print (“Values inside after the function call: ”, MyList)
return MyList
MyList = [10, 20, 30, 60]
print (“Values outside before the function call: ”,MyList)
Myreference (MyList)
print (“Values outside after the function call: ”,MyList)
7. Find the output of the following snippets:
def Character ():
p = 97
while (p<=100):
ch = chr(p)
print (ch)
p=p+1
return
Character()
8. Find the output of the following snippets:
def Operation (MyList):
MyList.extend([86, 52, 45])
MyList.pop()
MyList.sort()
print (MyList)
return
list1 = [25, 91, 61, 24, 74, 33, 79, 90]
Operation (list1)
9. Find the output of the following snippets:
num=1
def myfunc():
num = 10
return num
print (num)
print (myfunc())
print (num)
10. Define the following term with suitable example:
(a) Global variable
(b) Immutable data type
(c) Positional arguments
(d) Mutable data type

11. Write a Python code to accept a string from the user. Pass the string to a function
def Change(s) which displays the first character of each word after changing the case
(lower to upper and vice versa).
Sample Input: Delhi public school
Sample Output:
d
P
S

12. Write Python code to accept ten different names in a list and pass the list to a function def Search(MyList).
Enter a number in the function block and check whether the number is present or not by using ‘Linear Search
Technique’.
If the number is present then display ‘Search is successful’, otherwise display ‘Search is unsuccessful’.

You might also like