Class 12 Questions : Function Set 1

6.
What is the output of the below program?

x = 50
def func():
    global x
    print('x is', x)
    x = 2
    print('Changed global x to', x)
func()
print('Value of x is', x)

a) x is 50
Changed global x to 2
Value of x is 50
b) x is 50
Changed global x to 2
Value of x is 2
c) x is 50
Changed global x to 50
Value of x is 50
d) None of the mentioned

7.
What is the output of below program?

def say(message, times = 1):
    print(message * times)
say('Hello')
say('World', 5)

a)
Hello
WorldWorldWorldWorldWorld
b)
Hello
World 5
c)
Hello
World,World,World,World,World
d)
Hello
HelloHelloHelloHelloHello

8.
What is the output of the below program?

def func(a, b=5, c=10):
    print('a is', a, 'and b is', b, 'and c is', c)
func(3, 7)
func(25, c = 24)
func(c = 50, a = 100)

a)
a is 7 and b is 3 and c is 10
a is 25 and b is 5 and c is 24
a is 5 and b is 100 and c is 50
b)
a is 3 and b is 7 and c is 10
a is 5 and b is 25 and c is 24
a is 50 and b is 100 and c is 5
c)
a is 3 and b is 7 and c is 10
a is 25 and b is 5 and c is 24
a is 100 and b is 5 and c is 50
d) None of the mentioned

9.
What is the output of below program?

def maximum(x, y):
    if x > y:
        return x
    elif x == y:
        return 'The numbers are equal'
    else:
        return y
print(maximum(2, 3))

a) 2
b) 3
c) The numbers are equal
d) None of the mentioned

 

10.
Which are the advantages of functions in python?

a) Reducing duplication of code
b) Decomposing complex problems into simpler pieces
c) Improving the clarity of the code
d) All of the mentioned