FDS Week 3: Python question

FDS Week 3: Python question
0

Hello,

I was trying example of “Variables” in Week 3.

Sir mentioned that if we reassigned another_school to another name, say “IIT Madras”, we do as below. And when we re-run the previous cell, id of another_school would change to that of “IIT Madras”.

I tried it but don’t see id changing - it still points to “Padhai”…

any pointers…

Thanks

another_school = “Padhai”
print (another_school)
print (id(another_school))

Padhai
140021289668312

another_school = “IIT Madras”
print (another_school)
print (id(another_school) )

IIT Madras
140021289422328

And when we re-run the previous cell, id of another_school would change to that of “IIT Madras”.---- this is not correct, when you tried to assign a different name, you can see that id of another_School has now changed.
another_school is now pointing to an object “IIT Madras” which is stored in a different memory location i.e id

2 Likes