Avatto>>DATA SCIENTIST>>SHORT QUESTIONS>>Python Interview Questions
A Namespace in Python is a mapping between a name and an object. It is currently implemented as Python dictionary.
E.g. the set of built-in exception names, the set of built-in names, local names in a function

At different moments in Python, different Namespaces are created. Each Namespace in Python can have a different lifetime.

For the list of built-in names, Namespace is created when Python interpreter starts.

When Python interpreter reads the definition of a module, it creates a global namespace for that module.

When Python interpreter calls a function, it creates a local namespace for that function.
Some of the built-in data types available in Python are as follows:

Numeric types: These are the data types used to represent numbers in Python.
int: It is used for Integers
long: It is used for very large integers of non-limited length.

float: It is used for decimal numbers.

complex: This one is for representing complex numbers

Sequence types: These data types are used to represent a sequence of characters or objects.

str: This is similar to String in Java. It can represent a sequence of characters.

bytes: This is a sequence of integers in the range of 0-255.

byte array: like bytes, but mutable (see below); only available in Python 3.x

list: This is a sequence of objects.

tuple: This is a sequence of immutable objects.

Sets: These are unordered collections.

set: This is a collection of unique objects.

frozen set: This is a collection of unique immutable objects.

Mappings: This is similar to a Map in Java.

dict: This is also called hashmap. It has key-value pair to store information by using hashing.

Main differences between List and Dictionary data types in Python are as follows:

                 1. Syntax: In a List, we store objects in a sequence. In a Dictionary, we store objects in key-value pairs.



                  2. Reference: In List, we access objects by index number. It starts at 0 indexes. In a Dictionary we access objects by key specified at the time of Dictionary creation.



                  3. Ordering: In a List, objects are stored in an ordered sequence. In a Dictionary objects are not stored in an ordered sequence.



                  4.Hashing: In a Dictionary, keys have to be hashable. In a List, there is no need for hashing.



Description