Assignment Functions
Assignment Functions
Assignment Functions
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.
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:
(ii)
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”}