Variables and assignments in Python, How to create a variable in Python, How to assign a value to a variable in Python
Python is a loosely typed(loosely coupled) programming language it means Python’s variables do not need to be “declared” as holding a specific type of value, as in some other programming languages like C, C++, Java etc we must need to declare a variable with its specific type like int, float,double etc. Python is a “dynamically typed” language.Value assigned to the variable to convert implicitly to the its type and any range we can give it.
>>> shoo = 'Restaurant'
>>> shoo
'Restaurant'
>>> shoo = 4
>>> shoo
4
in above example, the variable shoo is mapped to a string object, 'Restaurant', but is then
remapped to an integer object, 4. Note the string that shoo used to refer to disappears, unless other variables are also referring to it (which is entirely possible!). Because you can remap variable names like this, you are never really 100 percent sure what type of object a variable is pointing to at any given time, unless you ask the interpreter for more information.
Python is a loosely typed(loosely coupled) programming language it means Python’s variables do not need to be “declared” as holding a specific type of value, as in some other programming languages like C, C++, Java etc we must need to declare a variable with its specific type like int, float,double etc. Python is a “dynamically typed” language.Value assigned to the variable to convert implicitly to the its type and any range we can give it.
>>> shoo = 'Restaurant'
>>> shoo
'Restaurant'
>>> shoo = 4
>>> shoo
4
in above example, the variable shoo is mapped to a string object, 'Restaurant', but is then
remapped to an integer object, 4. Note the string that shoo used to refer to disappears, unless other variables are also referring to it (which is entirely possible!). Because you can remap variable names like this, you are never really 100 percent sure what type of object a variable is pointing to at any given time, unless you ask the interpreter for more information.
{ 0 comments... read them below or add one }
Post a Comment