What is the output of the following code ?
def func(a, b=4, c=5):
print(a, b, c)
func(1, 2)
What is the output of the following code ?
def func(x, y, z=5):
print(x, y, z)
func(1, y=3, z=2)
What is the output of the following code ?
def func(x, *args):
print(x, args)
func(1, 2, 3)
What is the output of the following code ?
def func(x, y, z=3, k=4):
print(x, y, z, k)
func(1, *(5, 6))
What is the output of the following code ?
def foo(p):
p[0] = 1
q = [0]
foo(q)
print(q)
What is the output of the following code ?
def foo(p):
p = ['pass', 'except']
return id(p)
e = ['None', 'True']
print(id(e) == foo(e))
What is the output of the following code ?
foo = lambda a, b: a if a < b else b
print(foo(5, 10))
What is the output of the following code ?
x = 10
y = 20
def foo():
global y
x = 45
y = 56
foo()
print(x, y)
If there is no return statement in a function, the function returns
What is the output of the following code ?
x = 27
def foo(a, b=x):
print(a,b)
x = 24
foo(7)
What is the output of the following code ?
x = 5
def foo():
global x
x = 4
def bar(a, b):
global x
return a + b + x
foo()
print(bar(7, 8))
What is the output of the following code ?
a, b = 1, 2
def foo():
global c
c = a + b
foo()
print(a, b, c)
What happens If you already have a global variable with the same name and you again define a new variable with same name ?
Which an is the correct about recursive function ?
What is the output of the following code ?
L = []
def foo(y):
if y == 0:
return L
num = y % 2
L.append(num)
foo(y//2)
foo(6)
L.reverse()
for i in L:
print(i, end=" ")