11.
What are the two main types of functions?
a) Custom function & User defined function
b) Built-in function & User defined function
c) User defined function & System function
d) System function & Built-in functions
Answer: b
EXPLANATION: Built-in functions and user defined ones. The built-in functions are part of the Python language. Examples are: dir(), len() or abs(). The user defined functions are functions created with the def keyword.
12.
Which of the following is the use of id() function in python?
a) Id returns the identity of the object
b) Every object doesn’t have a unique id
c) All of the mentioned
d) None of the mentioned
Answer: a
EXPLANATION: Each object in Python has a unique id. The id() function returns the object’s id.
13.
Which of the following refers to mathematical function?
a) sqrt
b) rhombus
c) add
d) fact
Answer: a
EXPLANATION: Functions that are always available for usage, functions that are contained within external modules, which must be imported and functions defined by a programmer with the def keyword.
Eg: math import sqrt
A sqrt() function is imported from the math module.
14.
What is the output of below program?
def cube(x):
return x * x * x
x = cube(3)
print( x)
a) 9
b) 3
c) 27
d) 30
Answer: c
EXPLANATION: A function is created to do a specific task. Often there is a result from such a task. The return keyword is used to return values from a function. A function may or may not return a value. If a function does not have a return keyword, it will send a none value.
15.
What is the output of the below program?
def C2F(c):
return c * 9/5 + 32
print (C2F(100))
print (C2F(0))
a) 212.0
32.0
b) 314.0
24.0
c) 567.0
98.0
d) None of the mentioned
Answer: a
EXPLANATION: The code shown above is used to convert a temperature in degree celsius to fahrenheit.