Class 12 Working with Functions Quiz

Preview



Working with Functions in Python Quiz

1 / 32

What is the order of resolving scope of a name in a Python program ?

(L : Local namespace, E : Enclosing namespace, B : Built-In Namespace, G : Global namespace )

2 / 32

What is the name given to that area of memory, where the system stores the parameters and local variables of a function call ?

3 / 32

What is the output of following code
n=5
def show():
     global n
     n=10
     print(n, end=" ")

print(n, end=" ")
show()
print(n)

4 / 32

A local variable having the same name as that of a global variable, hides the global variable in its function .

5 / 32

What is a variable defined outside all the functions referred to as ?

6 / 32

Variables defined inside functions can have global scope .

7 / 32

Which of the following function calls can be used to invoke the below function  definition ?

def test ( a,b,c,d )

8 / 32

The default values for parameters are considered only if no value is provided for that parameter in the function call statement .

9 / 32

What is a variable defined inside a function referred to as ?

10 / 32

A void function also returns multiple values .

11 / 32

What is the output of following code:
def show(a, n):
     a=a+10
     n=n-a
     print(a,n)
show(5,10)

12 / 32

What is the result of this code ?
def double (x) :
     print ( 2**x )
double (5)

13 / 32

Variables that are listed within the parentheses of a function header are called function variables .

14 / 32

Trace the following code :
1. def one():
2.    print('one')
3. def two():
4.    print('two')
5. one()
6. two()

15 / 32

A parameter having default value in the function header is known as:

16 / 32

Which of the following function calls will cause error while invoking the below function ?

def  test ( a , b, c, d )

17 / 32

Carefully observe the code and give the output

def  function (a) :
     a = a + ‘1’
     a = a * 2
     print (a)
function ( “hello” )

18 / 32

Default return value of a function that doesn't return any value is

19 / 32

In Python, the program execution begins with first statement of _main_segment .

20 / 32

A Python function may return multiple values .

21 / 32

Which of the following keywords marks the beginning of the following block ?
def show():
   print('hello')

22 / 32

Default parameters cannot be skipped in function call .

23 / 32

Which of the following statements is false for parameter passing to functions ?

24 / 32

Which of the following is a void function
def one():
     print('one')
def two():
     return('two')

25 / 32

Which of the following is a non void function
def one():
     print('one')
def two():
     return('two')
one()
print(two())

26 / 32

Which of the given argument types can be skipped from a function call ?

27 / 32

Which of the following function headers is correct ?

28 / 32

Which of the following items are present in the function header ?

29 / 32

What is the output of following code:
n=5
def show():
     n=10
     print(n, end=" ")

print(n, end=" ")
show()
print(n)

30 / 32

Pick one of the following statements to correctly complete the function body in the given code .
def  f (number) :     
     print(number)
print (f (5) )

31 / 32

The first line of function definition that begins with keyword def and ends with a colon ( : ), is also known as function header .

32 / 32

Non-default arguments can be placed before or after a default argument in a function definition .

Your score is

0%

Exit



 

Lesson tags: python quiz for class 12
Back to: CBSE class 12 Computer Science notes