Python MCQ Questions - Functions

Python MCQ Questions - This section focuses on "Functions" in Python programming. These python MCQ questions should be practiced to improve the Python programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. Which keyword is use for function?

A. define
B. fun
C. def
D. function

View Answer


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

A. function name
B. parameter list
C. return value
D. Both A and B

View Answer


3. What is called when a function is defined inside a class?

A. class
B. function
C. method
D. module

View Answer


4. If return statement is not used inside the function, the function will return:

A. None
B. 0
C. Null
D. Arbitary value

View Answer


5. What is a recursive function?

A. A function that calls other function.
B. A function which calls itself.
C. Both A and B
D. None of the above

View Answer


6. Which of the following is the use of id() function in python?

A. Id() returns the size of object.
B. Id() returns the identity of the object.
C. Both A and B
D. None of the above

View Answer


7. Which of the following function headers is 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)

View Answer


8. In which part of memory does the system stores the parameter and local variables of funtion call?

A. heap
B. stack
C. Uninitialized data segment
D. None of the above

View Answer


9. 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)

View Answer


10.  Which operator is used in Python to import modules from packages?

A. .
B. *
C. ->
D. &

View Answer


11. Where is function defined?

A. Module
B. class
C. Another Function
D. All of the above

View Answer


12. Lambda is a function in python?

A. True
B. False
C. Lambda is a function in python but user can not use it.
D. None of the above

View Answer


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

A. local variable
B. global variable
C. static Variable
D. automatic variable

View Answer


14. What is the output of the following program?

z = lambda x : x * x
print(z(6))

A. 6
B. 36
C. 0
D. error

View Answer


15. What is the output of the following program?

print(chr(ord(chr(97))))

A. a
B. A
C. 97
D. error

View Answer


16. How is a function declared in Python?

A. def function function_name():
B. declare function function_name():
C. def function_name():
D. declare function_name():

View Answer


17. Which one of the following is the correct way of calling a function?

A. function_name()
B. call function_name()
C. ret function_name()
D. function function_name()

View Answer


18. Choose the correct option with reference to below Python code?

def fn(a):
print(a)
x=90
fn(x)

A. x is the formal argument.
B. a is the actual argument.
C. fn(x) is the function signature.
D. x is the actual argument.

View Answer


19. Which one of the following is incorrect?

A. The variables used inside function are called local variables.
B. The local variables of a particular function can be used inside other functions, but these cannot be used in global space
C. The variables used outside function are called global variables
D. In order to change the value of global variable inside function, keyword global is used.

View Answer


20. You can also create your own functions, these functions are called?

A. built-in functions
B. user-defined functions
C. py function
D. None of the above

View Answer


21. Function blocks begin with the keyword?

A. define
B. fun
C. function
D. def

View Answer


22. The code block within every function starts with a ?

A. ;
B. ::
C. :
D. %

View Answer


23. A return statement with _____ arguments.

A. No
B. 1
C. 2
D. Any

View Answer


24. ___________ are the arguments passed to a function in correct positional order.

A. Required arguments
B. Keyword arguments
C. Default arguments
D. Variable-length arguments

View Answer






Also check :


Discussion



* You must be logged in to add comment.