Class 12 Questions : Function Set 2

11.
How are default arguments specified in the function heading?

a) identifier followed by an equal to sign and the default value
b) identifier followed by the default value within backticks (“)
c) identifier followed by the default value within square brackets ([])
d) identifier

12.
How are required arguments specified in the function heading?

a) identifier followed by an equal to sign and the default value
b) identifier followed by the default value within backticks (“)
c) identifier followed by the default value within square brackets ([])
d) identifier

13.
What is the output of the following code?

def fun(x):
    x[0] = ['def']
    x[1] = ['abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == fun(q))

a) True
b) False
c) None
d) Error

14.
What is the output of the following?

def fun(i, x=[]):
    x.append(x.append(i))
    return x
for i in range(3):
    y = fun(i)
print(y)

a) [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].
b) [[0], [[0], 1], [[0], [[0], 1], 2]].
c) [0, None, 1, None, 2, None].
d) [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].

15.
The output of the code shown below is:

def f1():
    x=15
    print(x)
x=12
f1()

a) Error
b) 12
c) 15
d) 1512