Python

Python

Function has 18 Questions
Which of the following is the use of function in python?

Functions are reusable pieces of programs
Functions don't provide better modularity for your application
you can't also create your own functions
All of the mentioned
Which keyword is use for function?

Fun
Define
Def
Function
What is the output of the below program?
  1. def sayHello():
  2.     print('Hello World!') 
  3. sayHello() 
  4. sayHello()

Hello World! Hello World!
'Hello World!' 'Hello World!'
Hello Hello
None of the mentioned
What is the output of the below program?
  1. def printMax(a, b):
  2.     if a > b:
  3.         print(a, 'is maximum')
  4.     elseif a == b:
  5.         print(a, 'is equal to', b)
  6.     else:
  7.         print(b, 'is maximum')
  8. printMax(3, 4)

3
4
4 is maximum
None of the mentioned
What is the output of the below program?
  1. x = 50
  2. ?
  3. def func():
  4.     global x
  5. ?
  6.     print('x is', x)
  7.     x = 2
  8.     print('Changed global x to', x)
  9. func()
  10. print('Value of x is', x)

x is 50 Changed global x to 2 Value of x is 50
x is 50 Changed global x to 2 Value of x is 2
x is 50 Changed global x to 50 Value of x is 50
None of the mentioned
What is the output of below program?
  1. def say(message, times = 1):
  2.     print(message * times)
  3. ?
  4. say('Hello')
  5. say('World', 5)

Hello WorldWorldWorldWorldWorld
Hello World 5
Hello World,World,World,World,World
Hello d
What is the output of the below program?
  1. def func(a, b=5, c=10):
  2.     print('a is', a, 'and b is', b, 'and c is', c)
  3. ?
  4. func(3, 7)
  5. func(25, c = 24)
  6. func(c = 50, a = 100)

a is 7 and b is 3 and c is 10 a is 25 and b is 5 and c is 24 a is 5 and b is 100 and c is 50
a is 3 and b is 7 and c is 10 a is 5 and b is 25 and c is 24 a is 50 and b is 100 and c is 5
a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50
None of the mentioned
Which of the following is a features of DocString?

Provide a convenient way of associating documentation with Python modules, functions, classes, and methods
All functions should have a docstring
Docstrings can be accessed by the __doc__ attribute on objects
All of the mentioned
What is called when a function is defined inside a class?

Module
Class
Another function
Method
Which of the following is the use of id() function in python?

Id returns the identity of the object
Every object doesn't have a unique id
All of the mentioned
None of the mentioned
Which of the following refers to mathematical function?

sqrt
rhombus
add
rhombus
What is the output of the below program?
  1. def C2F(c):
  2.     return c * 9/5 + 32
  3. print C2F(100)
  4. print C2F(0)

212 32
314 24
567 98
None of the mentioned
What is the output of the below program?
  1. def power(x, y=2):
  2.     r = 1
  3.     for i in range(y):
  4.        r = r * x
  5.     return r
  6. print power(3)
  7. print power(3, 3)


212 32
9 27
567 98
None of the mentioned
What is the output of this program?
  1. y = 6
  2. ?
  3. z = lambda x: x * y
  4. print z(8)

48
14
64
None of the mentioned
What is the output of below program?
  1. lamb = lambda x: x ** 3
  2. print(lamb(5))

15
555
125
None of the mentioned
Is Lambda contains return statements?

True

 False
What is the output of below program?
  1. def writer():
  2. 	title = 'Sir'
  3. 	name = (lambda x:title + ' ' + x)
  4. 	return name
  5. ?
  6. who = writer()
  7. who('Arthur')

Arthur Sir
Sir Arthur
Arthur
None of the mentioned
What is the output of this program?
  1. min = (lambda x, y: x if x < y else y)
  2.  min(101*99, 102*98)

9997
9999
9996
None of the mentioned