Python 3 – How to Check Type of Variable?

Variable is created when a value is assigned to them. They are used for storing some values. In Python, types of a variable are interpreted automatically by the engine. We don’t need to declare them explicitly like other programing languages.

But to check the data type of a variable in Python 3, use the type() function as shown below:

int_var = 10
type(int_var) # OUTPUT as int

str_var = "Jolly"
type(str_var) #OUTPUT as str

flt_var= 10.56
type(flt_var) #OUTPUT as float

bool_var= True
type(bool_var) #OUTPUT as bool

 

 

We used Jupyter Notebook to run Python commands on local. Refer to this tutorial to set it up in your local environment.

Leave a Reply

Your email address will not be published. Required fields are marked *