Working With Functions Question
Working With Functions Question
Ques1) Explain the use of positional parameters in python with the help of suitable example
Ques2) Explain the use of default parameter in python function with the help of example
Ques3)
Ques4)
Ques5)
Ques6)
Ques 7)
Ques8)
Ques9)
Ques10)
Ques 11)
Ques 12) 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 Non-Zero
Elements of L.
Ques 13) Which of the following components are part of a function header in Python?
Ques 15) Which of the following is the correct way to call a function?
Ques 16)
Ques 17)
Ques 18)
Ques 19)
Ques 20)
Ques 21) Differentiate between actual &a formal parameter with a suitable example in python
Ans)
Example :
A=5
B= 2
Ques 22) Explain the use of global key word used in a function with the help of a suitable example.
Ans) In Python, global keyword allows the programmer to modify a variable outside the current
scope. It is used mostly in functions to change global scope variable locally . It is writtern inside the
function to us global value of a variable. Outside the function global keyword has no affect
Def Sum(sum):
Global c
C+=sum
Sum(20);
Ques 24)
Ques 25)
Ques 26) Assertion (A): In the case of positional arguments, the function call and function definition
statements match in terms of the number and order of arguments.
Reasoning (R): During a function call, positional arguments should precede keyword arguments in
the argument list.
(B)Both A and R are true and R is not the correct explanation for A
Ques 27)
Ques 28) Find and write the output of the following python code:
Ques 29) What do you understand by local & global scope of variables ? give example How can you
access global variable inside the function , if function has a variable with same name.
Ques30)
a)
b)
c)
Ques 32)
Ques 33)
Ques 34)
Ques 35)
Ques 36)
Ques 37)
Ques 38)
Ques 39)
Ques 40)
Ques 41)
Ques 42)