Which one is the out of the following code ?
def foo(arg):
arg += '3'
arg *= 3
return arg
print(foo('pythoneasy'))
What is the output of the following code ?
p = [23, 2, 0, 0, 'welcome', '', {}]
print(list(filter(bool, p)))
What is the output of the following code ?
def find_maximum(x, y):
if x > y:
print(x, 'is maximum')
elif x == y:
print(x, 'is equal to', y)
else:
print(y, 'is maximum')
find_maximum(10, 2)
What is the output of the following code ?
def add(*args):
'''Function returns the sum of all values passed to it'''
r = 0
for i in args:
r += i
return r
print(add.__doc__)
print(add(7, 8, 9))
print(add(7, 8, 9, 10, 11))
What is the output of the following code ?
foo = lambda x: x ** 3
print(foo(3))
What is the output of the following code ?
def foo():
x = 89
print(x)
x += 21
foo()
What is the output of the following code ?
def foo():
global x
x += 1
print(x)
x = 12
foo()
print(x)
What is the output of the following code ?
def bar(x, y=[]):
y.append(x)
return y
print(bar(7, [8, 9]))
What is the output of the following code ?
def foo(x):
print("outer function")
def bar(a):
print("inner function")
print(a,x)
foo(3)
bar(1)
Which of the following variables are global ?
a, b = 1, 2
def foo():
global c
c = a + b
What is the output of the following code ?
x = "python"
def foo(k): print(k) + x
foo("cpython")
_________ returns a dictionary which contains module namespace.
_________ returns a dictionary which contains current namespace.
Which of the following is not correct ?
In a recursive function, what happens if the base condition is not defined ?
What is the output of the following code ?
def foo(x):
if x == 0:
return 0
elif x == 1:
return 1
else:
return foo(x-1)+foo(x-2)
for i in range(0, 6):
print(foo(i), end=" ")