Python Coding Interview Questions

Avatto > > DATA SCIENTIST > > SHORT QUESTIONS > > Python Coding Interview Questions

Python Flask is a micro-framework based on Python to develop a web application.

It is a very simple application framework that has many extensions to build an enterprise level application.

Flask does not provide a data abstraction layer or form validation by default. We can use external libraries on top of Flask to perform such tasks.
A frozenset is a collection of unique values in Python. In addition to all the properties of set, a frozenset is immutable and washable.

Once we have set the values in a frozenset, we cannot change. So we cannot use and update methods from a set on frozenset.

Being hashable, we can use the objects in frozenset as keys in a Dictionary.
A metaclass in Python is also known as class of a class. A class defines the behavior of an instance. A metaclass defines the behavior of a class.

One of the most common metaclass in Python is type. We can subclass type to create our own metaclass.

We can use metaclass as a class-factory to create different types of classes.
Some of the main benefits of using Python are as follows:

Easy to learn: Python is simple language. It is easy to learn for a new programmer.

Large library: There is a large library for utilities in Python that can be used for different kinds of applications.

Readability: Python has a variety of statements and expressions that are quite readable and very explicit in their use. It increases the readability of the overall code.

Memory management: In Python, memory management is built into the Interpreter. So a developer does not have to spend effort on managing memory among objects.

Complex built-in Data types: Python has built-in Complex data types like list, set, dict etc.

These data types give a very good performance as well as save time in coding new features.
In Python we have two options to copy an object. It is similar to cloning an object in Java.

Shallow Copy: To create a shallow copy we call copy.copy(x). In a shallow copy, Python creates a new compound object based on the original object. And it tries to put references from the original object into copy object.

Deep Copy: To create a deep copy, we call copy.deepcopy(x). In a deep copy, Python creates a new object and recursively creates and inserts copies of the objects from original object into copy object. In a deep copy, we may face the issue of recursive loop due to infinite recursion.