Working With Functions - Set 1 - QP
Working With Functions - Set 1 - QP
say('Hello')
1.Which of the following is the use of say('World', 5)
function in python?
a) Functions are reusable pieces of programs
b) Functions don’t provide better modularity 8.What is the output of the below program?
for your application def func(a, b=5, c=10):
c) you can’t also create your own functions print('a is', a, 'and b is', b, 'and c is', c)
d) All of the mentioned func(3, 7)
func(25, c = 24)
func(c = 50, a = 100)
2.Which keyword is use for function?
a) fun
b) define 9.What is the output of below program?
c) def def maximum(x, y):
d) function if x > y:
return x
elif x == y:
3.What is the output of the below program? return 'The numbers are equal'
def printMax(a, b): else:
if a > b: return y
print(a, ‘is maximum’) print(maximum(2, 3))
elif a == b:
print(a, ‘is equal to’, b)
else: 10.Which are the advantages of functions in
print(b, ‘is maximum’) python?
printMax(3, 4) a) Reducing duplication of code
b) Decomposing complex problems into
simpler pieces
4.What is the output of the below program? c) Improving the clarity of the code
def sayHello(): d) All of the mentioned
print('Hello World!')
sayHello()
sayHello() 11.What are the two main types of
functions?
a) Custom function & User defined function
5.What is the output of the below program ? b) Built-in function & User defined function
x = 50 c) User defined function & System function
def func(x): d) System function & Built-in functions
#print(‘x is’, x)
x=2
#print(‘Changed local x to’, x) 12.Which of the following is the use of id()
func(x) function in python?
print(‘x is now’, x) a) Id returns the identity of the object
b) Every object doesn’t have a unique id
c) All of the mentioned
6.What is the output of the below program? d) None of the mentioned
x = 50
def func():
global x 13.Which of the following refers to
print('x is', x) mathematical function?
x=2 a) sqrt
print('Changed global x to', x) b) rhombus
func() c) add
print('Value of x is', x) d) fact