top of page
Writer's pictureRajesh Singh

Python Function MCQ Questions

Updated: 2 days ago

Function Python Chapter MCQ

Q1. Function keyword use

      (a). define

      (b). fun

      (c). def

      (d). function

       Answer-(c)

Q2. Function header items present

     (a). function name

     (b). parameter list

     (c). return value

     (d). Both(a)and(b)

     Answer-(d)

Q3. Function class defind

     (a). class

     (b). function

     (c). method

     (d). module

    Answer-(c)

Q4. Function return statement function return

     (a). none

     (b). 0

     (c). null

     (d). Arbitary value

    Answer-(a)


   Q 5. Recursive function

       (a). funtion other function call

       (b). A function which calls itself

       (c). Both (a)and(b)

       (d). None of these

     Answer-(b)

Q6. Python id() use

      (a). Id() returns the size of object

      (b). Id() returns the idenity of the object

      (c). Both(a)and(b)

      (d). None of above

      Answer-(b)

Q7. Function header correct

     (a). def fun (a=2,b=3,c)

     (b). def fun (a=2,b,c=3)

     (c). def fun (a,b=2,c=3)

     (d). def fun (a,b,c=3,d)

     Answer-(c)

Q8. In which part of memory does the system stores the parameter and local variable of function call ?

     (a). heap

     (b). stack

     (c). Uninitialized data segment

     (d). None of above

      Answer-(b)



Q9. Which of the following will print the pi value defined in math module?

     (a). print(pi)

     (b). print(math.pi)

     (c). from math import pi print(pi)

     (d). from math import pi print(math.pi)

     Answer-(c)

Q10. Packages modules import operator python used

      (a). * (b). .

       (c). -> (d). &

       Answer-(b)

Q11. Function define

       (a). module

       (b). class

       (c). Another function

       (d). All of the above

     Answer-(d)

Q12. Python lambda function

       (a). true

       (b). false

       (c). Lambda is a function in python but user can is it.

       (d). None of the above

       Answer-(a)

Q13. What is a variable defind outside a function referred to as?

       (a). local variable

       (b). global variable

       (c). static variable

       (d). None of above

        Answer-(b)

Q14. What is the output of following program

         Z=lambda x:x*x

         Print(z(6))

      (a). 6 (b). 36  (c). 0 (d). error

      Answer-(b)

Q15. What is the output of below python program.

       (a). a

       (b). A

       (c). 97

       (d). error

       Answer-(a)

Q16. How is a function declared in python?

       (a). def function function_name():

       (b). declared function function_name()

       (c). def function_name()

       (d). declare function_name()

        Answer-(c)



Q17. Which is the correct way of calling function?

       (a). function_name()

       (b). call function_name()

       (c). both(a)and(b)

       (d). None of above

       Answer-(a)

Q18. Choose the correct option with reference to below python code?

          def fn(a):

                      print(a)

           x=90

          fn(x)

        (a). x is the format argument

        (b). a is the actuial argument

        (c). fn(x) is the function signature

        (d). x is the actual argument

        Answer-(d)

Q19. You can also create your own function,these function are called.

        (a). built in function

        (b). user defined function

        (c). py function

        (d). None of above

        Answer-(b)



Q20. The code block within arry fuction status with a?

       (a). ; (b). : :

       (c). : (d). %

       Answer-(c)

Q21. A return statement with_____agruments.

        (a). No

        (b). 1

        (c). 2

        (d). Any

        Answer-(a)

Q22. ____ are tge argument passed to a function is correct positional order.

         (a). Required argument

         (b). keyword argument

         (c). Default argument

         (d). variable lenth argument

         Answer-(c)

Q23. Output of following python code.

           Def say Hello():

                   print(‘Hello world!’)

            say Hello()

            say Hello()

          (a). Hello world!

                 Hello word!

          (b). Hello

                 Hello

          (c). world!

          (d). world!

                  Hello

          Answer-(a)

Q24. What is output:-

           Def print Max(a,b):

                    if a>b:

            elif a==b:

                   print(a, ’is equal to’,b)

             else:

                    print(b, ‘is maximum’)

             print Max(3,4)

          (a). 3

          (b). 4

          (c). 4 is maximum

          (d). None

          Answer-(c)

Q25. What is output:-

           x=50

           def func(x):

                        print(‘x is’,x)

                        x=2

                      print(‘changed local x to’ ,x)

            fun(x)

            print(‘x is now’ ,x)

           (a). x is 50 changed local x to 2 x is now 50

           (b). x is 50 changed local x to 2 x is now 2

           (c). x is 50 changed local x to 2 x is now 100

           (d). None of above

           Answer-(a) 

Q26. Which is the use of function in python?

A.    It are reusable pieces of programs

B.    It don’t provide better modularity for application

C.   We can’t also create your own functions

D.   All of the mentioned

Ans: A

Q27. What is the output of following python code?

def career():

 print('Career Bodh!')

career()

career()

A.    Career Bodh!

            Career Bodh!

B.     'Career Bodh!'

           'Career Bodh!'

C.   Career

Career

D.   None of ABOVE

Ans: A

Q28. What is the output of following code?

def career(message, times = 1):

    print(message * times)

career('Hey')

career('World', 4)

A.    Hey

          WorldWorldWorldWorld

B.    Hey

         World 4

C.   Hey

          World,World,World,World 

D.   None of Above

Ans: A

Q29. What is the output of following python code?

def fun(x, y=5, z=10):

    print('x is', x, 'and y is', y, 'and z is', z)

 

fun(3, 7)

fun(25, z = 24)

fun(z = 50, x = 100)

A.    x is 7 and y is 3 and z is 10

           x is 25 and y is 5 and z is 24

           x is 5 and y is 100 and z is 50

B.    x is 3 and y is 7 and z is 10

           x is 25 and y is 5 and z is 24

          x is 100 and y is 5 and z is 50

C.   Both A & B

D.   None of Above

Ans: B

Q30. What is the main purpose of a function in Python?

A.    To execute a block of code again and again

B.    To organize code into manageable units and promote code reuse

C.   To perform Logical operations

D.   None of Above

Ans: B

 

13 views0 comments

Recent Posts

See All

Files MCQ in Python

File Processing MCQ Q1. Which function writes a list of lines in File? A.      Writelines() B.      Write() C.      Tell() D.      All of...

Python List MCQ Questions

Q1. What is output of below python code? dict= {1:'1', 2:'2', 3:'3'} del dict[1] dict[1] = '10' del dict[2] print (len(dict)) A. 1 B. 2...

Python NUMPY MCQ Questions

Python NumPy Chapter MCQ: 1. What will be print? Import numpy as np a = np. array([1,2,3,5,8]) b = np. array([0,3,4,2,1]) c = a+b c = c*a...

Opmerkingen


bottom of page