Mutable and immutable type?

800    Asked by seemaDeshpande in Data Science , Asked on Jan 7, 2020
Answered by seema Deshpande

Values that can be changed are known as mutable values and which we cannot change are called immutable. In python some values we can modify but some we cannot, which we cannot change, we assign them new values because we cannot alter them.

Integers, floating numbers, strings all are immutable types. We change these values by assigning new values using the assignment operator. For example:

A = 2
A = 3
B = ‘Janbask
B = ‘Janbask Training

In both examples, we are just assigning new values to the same variable. We will explain in a later chapter about mutable values in detail but in shortlist and Dictionary are mutable because we can change their values.



Your Answer

Interviews

Parent Categories