Learn Python in Less than 8 Hrs Sitting @ Home /Desk with HandsOn

Q81. What is the purpose of pass in Python?

Ans: Suppose you are designing a new class with some methods that you don't want to implement, yet.

class MyClass(object):

    def meth_a(self):


    def meth_b(self):

        print "I'm meth_b"


If you would leave out the pass, the code wouldn't run. To summarize, the pass statement does nothing particular but can act as a placeholder.

However, there are many more usage but in short that is.


Q82. Which all are Python web scrapping libraries?

Ans : There are following Python web scrapping libraries are available

-          The Farm: Requests

-          The Stew: Beautiful Soup 4

-          The Salad: lxml

-          The Restaurant: Selenium

-          The Chef: Scrapy


Q83. What is the purpose of the with statement in Python?

Ans : In python the with keyword is used when working with unmanaged resources (like file streams). It allows you to ensure that a resource is "cleaned up" when the code that uses it finishes running, even if exceptions are thrown. It provides 'syntactic sugar' for try/finally blocks.


It’s handy when you have two related operations which you’d like to execute as a pair, with a block of code in between. The classic example is opening a file, manipulating the file, then closing it:

 with open('HadoopExam.txt', 'w') as f:

     f.write('Welcome to HadoopExam Learning Resources…')

The above with statement will automatically close the file after the nested block of code. (Continue reading to see exactly how the close occurs.) The advantage of using a with statement is that it is guaranteed to close the file no matter how the nested block exits. If an exception occurs before the end of the block, it will close the file before the exception is caught by an outer exception handler. If the nested block were to contain a return statement, or a continue or break statement, the with statement would automatically close the file in those cases, too.


Q84. What is the difference between {} dictionary and “OrderedDict”?

Ans: OrderedDict maintain the insertion order. In whatever order all the key value pairs are added to dictionary will be maintained and that cannot be possible with the regular dictionary.


Q85. Which is faster when we need to apply search operation on list and dictionary?

Ans : Dictionary will be faster than list, if you search based on the key.


Q86. What is the purpose of the enumerate in Python?

Ans : The enumerate() function adds a counter to an iterable. So for each element in cursor, a tuple is produced with (counter, element); the for loop binds that to row_number and row, respectively.


elements = ('foo', 'bar', 'baz')

for count, elem in enumerate(elements):

...     print count, elem


0 foo

1 bar

2 baz


Q87. What is a regular expression?

Ans : A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager.


Q88. What is NumPy?

Ans: NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. NumPy is open-source software and has many contributors.


Q89. What is the matplotlib?

Ans: matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. It provides an object-oriented API for embedding plots into applications using general-purpose GUI toolkits like Tkinter, wxPython, Qt, or GTK+. SciPy makes use of matplotlib.

Rounded Rectangle: Learn Python in less than 8 Hrs (Sitting @ Home/Desk) 


Q90. What is TkInter?

Ans: Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit, and is Python's de facto standard GUI. Tkinter is included with the standard Microsoft Windows and Mac OS X install of Python. The name Tkinter comes from Tk interface.


 Learn Python in Less than 8 Hrs Sitting @ Home /Desk with HandsOn