Data types

Info:

Variables can store data of different types. In Python, you have the following data types by default:

Getting the Data Type:

You can get the data type of any object by using thetype() function:

x = 5
print(type(x))

This should give an output that gives information about the data type of the variable x:

<class 'int'>

So as you see above, the output tells us that the data type of the x variable's value is an integer.

Setting the Data Type:

In Python, the data type is set when you assing a value to a variable:

Examples:
You can also set a specific data type:
Note

Note how the syntax changes from brackets..etc to paranthesis when you set a specific type.