In Python a variable is a name stuck onto an object. Watch names get created, move to new objects, and share one object.
Python · beginner · 6 min · 7 steps · free
age = 30
name = "Asha"
age = age + 1 # makes a new number object; the name moves to it
nickname = name # two names, one string object
score = 9.5
is_member = True
print(name, age, nickname, score, is_member)age is a name for the integer object 30. Python works out the type from the value; there is no type to declare.name, for a string object. Text goes in quotes.age moves to it. The 30 itself never changed.nickname = name does not copy the text. Both names now point at the very same string object.True or False, with a capital letter.age = age + 1 changes the number 30 itself: it makes a new number objectis_membera = 5 then b = a then a = 6. What is b?Answer: 5. b still points at 5; only a moved to 6.
Answer: 9.5. A decimal point makes a float; quotes make a string.