Correct. A variable that has a string value at one point in time may have an int value later. IntelliJ tries to determine what the type is, but it's not perfect.
There's actually one way to tell IDEs what the type is: type hinting. It looks like you're specifying types, but it's just a hint for IDEs. The IDE can then issue a warning or error if you try to assign something else.
Monica Shiralkar wrote:Thanks. So it can be anything because it will be know at runtime only as Python is not compiled language ?
Note precisely. Especially since for performance reasons, Python does get "compiled" these days on most machines. That's what those ".pyc" files are.
It's just that interpreted languages historically have been weakly type and compiled languages historically have been more strongly typed.
Part of that history had to do with the fact that old-time computers were so much slower and simpler that your smartwatch could literally out-perform them. So building complex internal data structures to keep track of assignable data types and spending time checking them wasn't really worth it. Keeping both the compiler AND the run-time interpreter in RAM made for crowded RAM.
So what typing was done was things like having a naming convention for variables (Integers start with I-N, strings end with "$" and so forth). And over time a lot of people got impatient with even those restrictions.
Sources may include data from the Fakebook Research Foundation with support from Gargle University