Class 12 Questions : Function Set 3 1

1.
What is the output of the code shown below?

x=100
def f1():
    global x
    x=90
def f2():
    global x
    x=80
print(x)

a) 100
b) 90
c) 80
d) Error

 

2.
Read the code shown below carefully and point out the global variables:

y, z = 1, 2
def f():
    global x
    x = y+z

a) x
b) y and z
c) x, y and z
d) Neither x, nor y, nor z

 

3.
What is the output of the code shown below?

x=1
def cg():
	global x
	x=x+1	
cg()

a) 2
b) 1
c) 0
d) Error

 

4.
On assigning a value to a variable inside a function, it automatically becomes a global variable. State whether true or false.

a) True
b) False

 

5.
Which is the most appropriate definition for recursion?

a)A function that calls itself
b)A function execution instance that calls another execution instance of the same function
c)A class method that calls another class method
d)An in-built method that is automatically called