91. What is PEP8?
PEP8 consists of coding guidelines for Python language so that programmers can write readable code making it easy to use for any other person, later on.
92. Is all the memory freed when Python exits?
No, it is not, because the objects that are referenced from global namespaces of Python modules are not always de-allocated when Python exits.
93. What does _init_.py do?
a. init_.py is an empty py file used for importing a module in a directory. _init_.py provides an easy way to organize the files. If there is a module maindir/subdir/module.py,_init_.py is placed in all the directories so that the module can be imported using the following command-
b. import maindir.subdir.module
94. What is the different between range () and xrange () functions in Python?
range () returns a list whereas xrange () returns an object that acts like an iterator for generating numbers on demand.
95. How can you randomize the items of a list in place in Python?
Shuffle (lst) can be used for randomizing the items of a list in Python
96. What is a pass in Python?
Pass in Python signifies a no operation statement indicating that nothing is to be done.
97. If you are gives the first and last names of employees, which data type in Python will you use to store them?
You can use a list that has first name and last name included in an element or use Dictionary.
98. What happens when you execute the statement mango=banana in Python?
A name error will occur when this statement is executed in Python.
99. Optimize the below python code-word = ‘word’
a. print word.__len_()
b. Answer: print ‘word’._len_()
100. What is monkey patching in Python?
Monkey patching is a technique that helps the programmer to modify or extend other code at runtime. Monkey patching comes handy in testing but it is not a good practice to use it in production environment as debugging the code could become difficult.