top of page

Python Function MCQ Questions

Writer's picture: Rajesh SinghRajesh Singh

Updated: Dec 27, 2024

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

Questions which asked O Level Exam Jan 2023 NIELIT:

Q31. What is the output of the below Python code ?

def func(a, b=5, c=10):

print(‘a is’, a, ‘and b is’, b, ‘and c is’, c)

func(13, 17)

func(a=2, c=4)

func(5,7,9)

(A) a is 13 and b is 15 and c is 10

a is 2 and b is 5 and c is 4

a is 5 and b is 7 and c is 9

(B) a is 13 and b is 17 and c is 10

a is 2 and b is 4 and c is 4

a is 5 and b is 9 and c is 7

(C) a is 13 and b is 17 and c is 10

a is 2 and b is 5 and c is 4

a is 5 and b is 7 and c is 9

(D) None of the above

Ans: C

Q32. What is the output of the following Python code ?

def s(n1):

print(n1)

n1 = n1 +2

n2=4

s(n2)

print(n2)

(A) 6 4

(B) 4 6

(C) 4 4

(D) 6 6

Ans: C

Q33. What will be the output of the following Python code ?

d1={“abc”:5,”def”:6,”ghi”:7}

 print(d1[0])

(A) abc

(B) 5

(C) {“abc”:5}

(D) Error

Ans: D (def is not used as variable invalid character in indentifier)

Q34. What will be the output of the following Python code ?

def display(b, n):

while n > 0:

print(b,end="")

n=n-1

display('z',3)

A.      zzz

B.      zz

C.      Infinite loop

D.      Error

Ans: A

Q35. What is the output of following code?

a=set('abc')

b=set('cdef')

print(a&b)

(A) {‘c’}

(B) {‘a’,’b’,’c’,’d’,’e’,’f’}

(C) {c}

(D) None of these

Ans: A

Q36.  What is a variable defined outside a function referred to as ?

A.      A static variable

B.      A global variable

C.      A local variable

D.      An automatic variable

Ans: B

Q37. Choose the correct function declaration of fun1() so that we can execute the following two function calls successfully.

fun1(25, 75, 55)

fun1(10, 20)

A.      def fun1(**kwargs)

B.      def fun1(args*)

C.      No, it is not possible in Python

D.      def fun1(*data)

Ans: D

Q38. What will be the output of the following Python code ?

def power(x, y=2):

    r = 1

    for i in range(y):

       r = r * x

    return r

print power(3)

print power(3, 3)

(A) 212

       32

(B) 9

       27

(C) 567

      98

(D) None of the above

Ans: B

Q39. Which of the following is used to define a block of code in Python language?

A.      try

B.      Brackets

C.      Indentation

D.      Catch

Ans: C

Questions which asked O Level Exam July 2022 NIELIT:

Q40. What will be the output of the following Python code ?

def C2F(c) :

return c*9/5+32

print (C2F(100))

print (C2F(0))

(A) 212.0

32.0

(B) 314

24

(C) 567

98

(D) None of the above

Ans: A

Q41.







Function MCQ video:



 


41 views0 comments

Recent Posts

See All

For Loop MCQ in Python

Q1. What is the output of the following Python code? x={1:"X",2:"Y",3:"Z"} for i,j in x.items():     print(i,j,end=" ") A.    1 X 2 Y 3 Z...

Comments


bottom of page