91. What will be the output of the following Python code?
def f1(x):
global x
x+=1
print(x)
f1(15)
print("hello")
def f1(x):
global x
x+=1
print(x)
f1(15)
print("hello")
92. What will be the output of the following Python code?
def foo(x):
x = ['def', 'abc']
return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))
def foo(x):
x = ['def', 'abc']
return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))
93. What is the value stored in sys.argv[0]?
94. What will be the output of the following Python code?
def sayHello():
print('Hello World!')
sayHello()
sayHello()
def sayHello():
print('Hello World!')
sayHello()
sayHello()
95. What will be the output of the following Python code?
l=[1, 2, 3, 4, 5]
m=map(lambda x:2**x, l)
print(list(m))
l=[1, 2, 3, 4, 5]
m=map(lambda x:2**x, l)
print(list(m))
96. What will be the output of the following Python code?
import functools
l=[1,2,3,4]
print(functools.reduce(lambda x,y:x*y,l))
import functools
l=[1,2,3,4]
print(functools.reduce(lambda x,y:x*y,l))
97. What will be the output of the following Python code?
def foo():
total += 1
return total
total = 0
print(foo())
def foo():
total += 1
return total
total = 0
print(foo())
98. What is the type of sys.argv?
99. What will be the output of the following Python code?
m=reduce(lambda x: x-3 in range(4, 10))
print(list(m))
m=reduce(lambda x: x-3 in range(4, 10))
print(list(m))
100. Read the following Python code carefully and point out the global variables?
y, z = 1, 2
def f():
global x
x = y+z
y, z = 1, 2
def f():
global x
x = y+z
Read More Section(Functions in Python)
Each Section contains maximum 100 MCQs question on Functions in Python. To get more questions visit other sections.