Class 12 Questions : Function Set 1

21.
What is the output of the following piece of code?

def a(b):
    b.append(5)

c = [1, 2, 3, 4]
a(c)
print(len(c))

a)4
b)5
c)1
d)An exception is thrown

22.
What is the output of the following code?

a=10
b=20
def change():
    global b
    a=45
    b=56
change()
print(a)
print(b)

a)10
56
b)45
56
c)10
20
d)Syntax Error

23.
What is the output of the following code?

def change(i = 1, j = 2):
    i = i + j
    j = j + 1
    print(i, j)

change(j = 1, i = 2)

a)An exception is thrown because of conflicting values
b)1 2
c)3 3
d)3 2

24.
What is the output of the following code?

def change(one, *two):
   print(type(two))

change(1,2,3,4)

a)<class ‘Integer’>
b)<class ‘tuple’>
c)<class ‘Dictionary’>
d)An exception is thrown

25.
What is the output of the following code?

def display(b, n):
    while n > 0:
        print(b,end="")
        n=n-1
display('z',3)

a)zzz
b)zz
c)An exception is executed
d)Infinite loop