Variable Types in Python
In Python, variables are dynamically typed, meaning the type of a variable is inferred based on the value you assign to it.
For example, if we create a variable x and assign a value of 12 as in the example below:
x = 12The type of the variable x is inferred to be an integer type.
Another example:
x = "the letter x"The type of the variable x is inferred to be a string type.
We’ll learn about the integer and string type plus some additional types that variables can be on the next few pages.
Last updated on