How To Print Type Of Variable In Python — pythonpip.com

How To Print type of variable

Parameters

Example :

str = "Welcome to pythonpip" age = 34 salary = 7342.7 complex_num = 11j+21 a_list = ["name", "age", "salary"] emps = ("A", "B", "C") a_dict = {"A": "a", "B": "b", "C": "c"} print("The type is : ", type(str)) print("The type is : ", type(age)) print("The type is : ", type(salary)) print("The type is : ", type(complex_num)) print("The type is : ", type(a_list)) print("The type is : ", type(emps)) print("The type is : ", type(a_dict))
The type is : <class 'str'> The type is : <class 'int'> The type is : <class 'float'> The type is : <class 'complex'> The type is : <class 'list'> The type is : <class 'tuple'> The type is : <class 'dict'> ** Process exited - Return Code: 0 ** Press Enter to exit terminal

Python isinstance

Syntax :

Arguments:

Example

fvalue = 13.15 inst_t = isinstance(fvalue, float) print("Instance Type:", inst_t)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Parvez Alam

Parvez Alam

Hey, I am Parvez Alam. A software developer since 2009. I love learning and sharing knowledge. https://www.phpflow.com/