Assignment Functions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

ZION AND ALWIN GROUP OF SCHOOLS-CBSE

DEPARTMENT OF COMPUTER SCIENCE


CLASS-XII
Test_1RevisionTour_Functions
1. What will be the output of the following code?

a) 1 b) 2 c) 3 d) error
2. Mohini wants to know that the symbol : (colon) must be required with which of the
following function part?
a) function header b) function body c) return statement d) parameters
3. Which of the following are true in Python?
a) Functions are reusable components of a program
b) Modularity cannot be achieved through functions
c) Python allows creating user-defined functions
d) All of the above
4. Predict the output of the following python code.

a) 18 b) 11 c) 36 d) None of the above


5. Find and write the output of the following python code:

6. Find and write the output of the following python code:

7. Find and write the output of the following python code:


8. Write the definition of a method COUNTNOW(PLACES) to find and display those place
names in which there are more than five characters after storing the name of places in a
dictionary.
For example, if the dictionary PLACES contains:
{'1':"DELHI", '2':"LONDON", '3':"PARIS", '4':"NEWYORK", '5':"DUBAI"}
The following output should be displayed:
LONDON NEWYORK
9. What will be the output of the following Python code?

a) 1 b) 1 c) 2 d) none of the mentioned


2
10. Which of the following function header is incorrect?
a) def fun(a, b, c): b) def fun(a, b=5, c=6): c) def fun(a, b=8, c): d) def fun(a, b,
c=9):
11. Assertion (A): print(f1()) displays None, if the function f1() has no return statement.
Reason (R): A function always returns None, even if it has no return statement.
12. Assertion (A): If the arguments in function call statement match the number and order of
arguments as defined in the function definition, such arguments are called positional
arguments.
Reason (R): During a function call, the argument list first contains default argument(s)
followed by positional argument(s).
13. Find and write the output of the following python code:

14. Difference between Global scope and Local scope.


15. Find the missing statements in the following code

16. i) Can function return multiple values? If yes, how? Give an example.
ii) How is package different from a module?
17. Write a function LShift (Arr, n) python, where Arr is the list of numbers and n is a numeric
value by which all elements of the list are shifted to left for n number of times.
Sample Input data of the list
Arr= [10, 20, 30, 40, 12, 11] and n=2
Output should be,
[30, 40, 12, 11, 10, 20]
18. Which of the following function calls can be used to invoke the function definition?
def test(a,b,c,d):
a) test(10,20,30,40) b) test(a=10,20,30,40)
c) test(a=10,b=20,c=30,40) d) test(a=10,b=20,c=30,d=40)
19. What is the order of resolving scope of a name in a python program?
a)BGEL b) LEGB c) GEBL d) LBEG
20. Predict the output of the following code:

21. Find the errors in code given below:


(i) def change(n=10,a,c=9):
return n
(ii)

22. What will be the output of the following Python code?

(ii)

23. Select the output for the given code:


a) 4 @ 9 @ 3 @ 12 b) 4 @ 4 @ 3 @ 7
c) 9 @ 9 @ 3 @ 12 d) 9 @ 4 @ 3 @ 12
24. Which of the following function call(s) will give an error?
def sum(a,b=10):
a) sum(20,25) b) sum(a=20,b=25) c) sum(b=25) d) sum(a=20)
ASSERTION AND REASONING based questions. Mark correct choice as:
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
25. Assertion (A):- If the arguments in function call match the number and order of
arguments as defined in the function definition, such arguments are called positional
arguments.
Reasoning (R):- During a function call, the argument list first contains default
argument(s) followed by positional argument(s).
26. What will be the output for the following code?

27. What will be the output for the following code?

28. Predict the output for the following code:


a)
(b)

29. Write a function LtoD(lis) to gets a list of even number of strings as parameter and
converts the pairs of the list as key values of a dictionary and displays the resultant dictionary
For example:
If lis contains [“DINESH”, “RAMESH”, “AMAR”, “SURESH”, “KARN”,”ANVAR”]
Then the function LtoD(lis) should display
{“DINESH”: “RAMESH”, “AMAR”: “SURESH”, “KARN”:”ANVAR”}

30. Predict the output of the given code.

31. What is the output of the below program ?

32. Identify and correct the errors in the following program.


33. Write a function words_3letter(string), that takes a string as an argument and returns a
tuple containing the words whose length is 3.
For example, if the string is “Let us enjoy the day”, the tuple will have (‘Let’,’the’,’day’)

34. Write the output of the following code:

You might also like