What will be the output of the following Python code?
def foo(k): k[0] = 1 q = [0] foo(q) print(q)
[0]
[1]
[1, 0]
[0, 1]
one-star followed by a valid identifier
one underscore followed by a valid identifier
two stars followed by a valid identifier
two underscores followed by a valid identifier
zero
one
zero or more
one or more
def foo(fname, val): print(fname(val)) foo(max, [1, 2, 3]) foo(min, [1, 2, 3])
3 1
1 3
error
none of the mentioned
def foo(): return total + 1 total = 0 print(foo())
0
1
def foo(): total += 1 return total total = 0 print(foo())
def foo(x): x = ['def', 'abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
True
False
None
Error
one star followed by a valid identifier
getopt
os
getarg
main
identifier followed by an equal to sign and the default value
identifier followed by the default value within backticks (“)
identifier followed by the default value within square brackets ([])
identifier
def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
def f1(a,b=[]): b.append(a) return b print(f1(2,[3,4]))
[3,2,4]
[2,3,4]
[3,4,2]
list
set
dictionary
tuple
The local variable is shadowed
Undefined behavior
The global variable is shadowed
A function that calls itself
A function execution instance that calls another execution instance of the same function
A class method that calls another class method
An in-built method that is automatically called
Recursive function can be replaced by a non-recursive function
Recursive functions usually take more memory space than non-recursive function
Recursive functions run faster than non-recursive function
Recursion makes programs easier to understand
A recursive function that has two base cases
A function where the recursive functions leads to an infinite loop
A recursive function where the function doesn’t return anything and just prints the values
A function where the recursive call is the last thing executed by the function
Every recursive function must have a base case
Infinite recursion can occur if the base case isn’t properly mentioned
A recursive function makes the code easier to understand
Every recursive function must have a return value
Program gets into an infinite loop
Program runs once
Program runs n number of times where n is the argument given to the function
An exception is thrown