Python 

Interview Questions & Answers

Top 10

Python was developed by Guido van Rossum and was released first on February 20, 1991.

Python Introduction

What is Python?

Python is a high-level, interpreted, general-purpose programming language. Being a general-purpose language, it can be used to build almost any type of application with the right tools/libraries.

What is an Interpreted language?

An Interpreted language executes its statements line by line. Languages such as Python, Javascript, R, PHP, and Ruby are prime examples of Interpreted languages.

What is __init__?

__init__ is a contructor method in Python and is automatically called to allocate memory when a new object/instance is created. All classes have a __init__ method associated with them.

What is docstring in Python?

Documentation string or docstring is a multiline string used to document a specific code segment.

Explain how can you make a Python Script executable on Unix?

Script file must begin with #!/usr/bin/env python

What is the difference between Python Arrays and lists?

– Arrays in python can only contain elements of same data types i.e., data type of array should be homogeneous. It is a thin wrapper around C language arrays and consumes far less memory than lists. – Lists in python can contain elements of different data types i.e., data type of lists can be heterogeneous. It has the disadvantage of consuming large memory.

How do you create a class in Python?

To create a class in python, we use the keyword “class” as shown in the example below: class Employee: def __init__(self, emp_name): self.emp_name = emp_name

Is it possible to call parent class without its instance creation?

Yes, it is possible if the base class is instantiated by other child classes or if the base class is a static method.

What are some of the most commonly used built-in modules in Python?

– os – math – sys – random – re – datetime – JSON

Why is finalize used?

Finalize method is used for freeing up the unmanaged resources and clean up before the garbage collection method is invoked. This helps in performing memory management tasks.

For more interview questions / Technical quizzes