Mutable are those which could be edited after it is defined for example list whose elements can be edited even after defining, whereas in case of immutable we can not edit them for example String.
What is Mutable?
Mutuable are those data Types that can be edited after Declaration For example once a datatype is declared and at the same time it is required to add or delete something in it we can edit it For example List, The elements of it can be edited.
Lets x = [1,33,54, “Prakhar”, “Yadav], Now if we want to delete 1 and write it as 2 then we write as x=, Now the values of x will be changed as at index 0 there will be 2 instant of 1.
It simply shows how we can edit the existing value of the variable if the Value is mutable.
Examples of mutable are – Objects, arrays, maps, sets, Dates, Functions, Lists, etc.
What is Immutable?
Immutable is the value that could not be changed once it is defined. It is like anything you have defined during declaration n would not be changed anyhow. Just like Everything is fixed that is defined during the declaration.
Let x= “Prakhar” Now the value of x will be Fixed as Prakhar which we can not change, Yes we can take another variable and concatenate but the value or x can not be edited.
We may rewrite the variable if the variable is not defined as constant, Which can not even be rewritten, Once declared is fixed for whole projects for example the value of pie(If if is being used anywhere in the project) can be declared as constant then we can use it any time and can not be changed at any time.
Difference Values of Mutable and Immutable
Primitive Data Types
The building blocks of data manipulation are pure, simple values of data for example Integers, Float, String, and Boolean. They are types of data that could exist at the lowest level.
Non-primitive data types are the driven data types that are derived from main(Primitive data)Types of data. They are being also called sophisticated members as they used for storing a number of data not for single data, for example, we have to store 50- 70 data in a single variable, and we use nonreactive data structures to store for example Array where we can store a number of elements.
Learn more About List which is a non Primitive data structure.- List in Python
or we can learn from – Mygreatlearning.com