Function Assignment
Function Assignment
Q-1. What is the default return value for a function that does not
return any value explicitly?
A. function name
B. function name and parameter list
C. parameter list
D. return value
A. brackets
B. parentheses
C. curly braces
D. quotation marks
Q-5. What is the name given to that area of memory, where the
system stores the parameters and local variables of a function call?
A. a heap
B. storage area
C. a stack
D. an array
Q6Write python statement in the given missing line which will
correctly represent the function body in the given code snippet?
def f(number):
print(f(5))
func('Welcome')
func('Viewers', 3)
Q8. What is the output of the following code snippet?
func(y = 2, x = 1)
num = 1
def func():
num = 3
print(num)
func()
print(num)
num = 1
def func():
num = num + 3
print(num)
func()
print(num)
num = 1
def func():
global num
num = num + 3
print(num)
func()
print(num)
test(2, 1)
myList = [lambda x: x ** 2,
lambda x: x ** 3,
lambda x: x ** 4]
for f in myList:
print(f(3))
mylist = [10,20,30];
func( mylist );
print ("Values outside the function: ", mylist)
x = 50
def func():
global x
print('x is', x)
x = 2
print('Changed global x to', x)
func()
print('Value of x is', x)
Q17. Which of the following function calls can be used to invoke the
below function definition?
def test(a, b, c, d)
num=4
myfunc('Hello', num)
x, y = func(y = 2, x = 1)
print(x, y)
def func():
text = 'Welcome'
name = (lambda x:text + ' ' + x)
return name
msg = func()
print(msg('All'))
mylist = [1, 2, 3, 4]
addFunc(mylist)
print (len(mylist))
myList = [1, 2, 3, 4, 5]
def func(x):
x.pop()
x.pop()
x.insert(-1, 0)
print ("Inside func():", x)
func(myList)
print ("After function call:", myList)
for row in m:
for element in row:
if v < element: v = element
return v
print(fun(data[0]))
add('Carrot')
add('Beet Root')
add('Tomato')
print (len(fruit))
1. x = 50
2. def func(x):
3. print('x is', x)
4. x = 2
5. print('Changed local x to', x)
6. func(x)
7. print('x is now', x)
Q What will be the output of the following Python code?
1. x = 50
2. def func():
3. global x
4. print('x is', x)
5. x = 2
6. print('Changed global x to', x)
7. func()
8. print('Value of x is', x)
What will be the output of the following Python code?