0% found this document useful (0 votes)
2 views4 pages

Functions in Python

This document is a slip test for Class XII Computer Science focused on functions in Python, consisting of multiple-choice questions, code correction tasks, and function writing exercises. It assesses knowledge on return statements, function headers, variable types, and the ability to debug and write Python code. The test includes questions on calculating totals, manipulating strings, and generating lists based on conditions.
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)
2 views4 pages

Functions in Python

This document is a slip test for Class XII Computer Science focused on functions in Python, consisting of multiple-choice questions, code correction tasks, and function writing exercises. It assesses knowledge on return statements, function headers, variable types, and the ability to debug and write Python code. The test includes questions on calculating totals, manipulating strings, and generating lists based on conditions.
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

CLASS : XII MARKS : 25

SUBJECT : COMPUTER SCIENCE SLIPT TEST


(FUNCTIONS IN PYTHON)

1. If return statement is not used inside the function, the function will return: 1m
a) 0 b) None c ) Error d) Any integer

2. Which of the following items are present in the function header ? 1m


a) unction name only b) both function name and parameter list
c) parameter list only d) return value

3. Which of the following function headers is correct ? 1m


a) def f(a = 1, b): b) def f(a = 1, b, c = 2):
c) def f(a = 1, b = 1, c = 2): d) def f(a = 1, b = 1, c = 2, d):

4. What is a variable defined inside a function referred to as _____ 1m

a) A static variable b) A global variable c) A local variable d) An automatic variable

5. State True/False . A Python function may return multiple values. 1m

6. 2m
7) 2m

8. 2m

9. 2m
10) 2m

11. What will be the output of the following code ? 2m


def calculate_total(price, quantity=1, discount=0):
total = price * quantity
total -= total * (discount / 100)
return total
print(calculate_total(100))
print(calculate_total(100, 2))
print(calculate_total(100, 2, 10))

12. The following python code contains error(s). Rewrite the correct code and underline the
corrections made by you. 2m
def fun(a, b=3, c) :
Return a + b + c
x = fun (10, 20)
print(x)
13. Find and write the output of the following python code: 2m
def fun(s):
k=len(s)
m=" "
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
else:
m=m+'bb'
print(m)
fun('school2@com')
14. 3m
Write a function INDEX_LIST(L), where L is the list of elements passed as argument to
the function. The function returns another list named ‘indexList’ that stores the indices
of all even numbers of L.

For example: If L contains [12,4,1,6,1,11,20,56]


The indexList will have - [0,1,3,6,7]

15. A Function can call another function or itself? (True/False) 1m

You might also like