Into to python data structure

a= 10
b= 10

so in the map both a and b are having same address values i.e. 1234 is the address where value 10 is stored so both a and b will be pointing to the same address. But is we change the value of a in this case does it affect the value of b also becz the actual value at the memory adress got changed and it was refrred by both the variables.

Also how can we sure that the meory optimization is workingonly if the values are between -5 to 256.

Hey @Akshay986

The operation you are performing won’t have the desired result. I’ll explain why.
Assume a and b as pointers. So, whenever you assign another value to a like: a = 11, the address of 11 in memory is assigned to a. No change is made to the 1234 memory address (the concept of immutability). Checkout this demo:
image Hope this helps!

okay got it thanks… each time at new memory address will be assigned to the variable during change in value.

I am.not able to view/comment on my previous doubts. Please let me know where i can access them.

Hi @Akshay986,

You have understood it perfectly.
Regarding accessing your previous doubts, go to discuss.codingblocks.com and then all your doubts are available in the “Activity” section:

image
You can mark the doubt as resolved now in the “My Doubts” section.
Happy Learning!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.