Dynamic Typing
- a is now of data type string. And the very fact that I'm able to do that, change a variable's data type by changing the content in that variable, this is what's known as dynamic typing.
a = 3
a = "Hello"
-------------
a = (str)"Hello"
- Python is a language that's quite unique because on one hand it is strongly typed, in the sense that it holds on to the data type of the variable
- But the part where the language is dynamically typed is that even though it knows what type a variable is, it knows what type a function expects, you can also dynamically change the data type of any variable like this.
- Python allows you to change the data type of a variable just by assigning it to a different type of value.
- Dynamic typing is not a feature that's available in all programming languages. For example, languages like C or Java or Swift, you won't be able to do this. Once you create a variable and you give it a certain type of data, then it must forever hold on to that type of data.
Appendix
https://stackoverflow.com/questions/11328920/is-python-strongly-typ
- Strong typing means that the type of a value doesn't change in unexpected ways. A string containing only digits doesn't magically become a number, as may happen in Perl. Every change of type requires an explicit conversion.
- Dynamic typing means that runtime objects (values) have a type, as opposed to static typing where variables have a type.