Python Interview Questions

1. What is Python..? What are the benefits of using Python..?

Answer: Python is a programming language with objects, modules, threads, exceptions and automatic memory management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure and it is an open source.

2. Explain how python is interpreted.

Answer: Python program runs directly from the source code. Each type Python programs are executed code is required. Python converts source code written by the programmer into intermediate language which is again translated it into the native language / machine language that is executed. So Python is an Interpreted language.

3. How is memory managed in python..?

Answer

• Memory management in Python involves a private heap containing all Python objects and data structures. Interpreter takes care of Python heap and that the programmer has no access to it.

• The allocation of heap space for Python objects is done by Python memory manager. The core API of Python provides some tools for the programmer to code reliable and more robust program.

• Python also has a build-in garbage collector which recycles all the unused memory. When an object is no longer referenced by the program, the heap space it occupies can be freed. The garbage collector determines objects which are no longer referenced by the program frees the occupied memory and make it available to the heap space.

How Python is interpreted..?

AnswerPython language is an interpreted language. Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is again translated into machine language that has to be executed.

5. Explain pickling and unpickling.

Answer: pickle is a standard module which serializes & de-serializes a python object structure. pickle module accepts any python object converts it into a string representation & dumps it into a file(by using dump() function) which can be used later, process is called pickling. Whereas unpickling is process of retrieving original python object from the stored string representation for use.

6. What are the built-in type does python provides..?

Answer: On-Page Optimization is way to “SEO optimize” of website by page coding. For Example add Meta Title, Meta Description, Meta Keywords, Content Quality, Meta Keyword Density, Outbound Links, Image Alt tag in website.

7. What are the built-in type does python provides?

Answer: • There are mutable and Immutable types of Pythons built in types Mutable built-in types

• List

• Sets

• Dictionaries

8. What is pass in Python..?

Answer: Pass means, no-operation Python statement, or in other words it is a place holder in compound statement, where there should be a blank left and nothing has to be written there.

9. What are the features of Python..?

Answer:Easy To Understand Portable, Object-Oriented Open Source, Interpreted Language Large Libraries Supported

10. What are the list..?

Answer:The list is a datatype in which multiple values are stored in an ordered sequence.

11. What is inheritance in python..?

Answer:Inheritance derives the properties of one class to or inherits it from some another class. Python supports the following types of inheritance.

12. Write some of the common errors..?

Answer:TypeError, ValueError, NameError, IOError, IndexError, KeyError.

13. What is a decorator..?

Answer:Python decorator adds functionality to another function, without modifying it.

14. How to import a module/library..?

Answer:using the import keyword, we can import any library or module in the code.