We can check the data type of a variable using the type() function.

file: 10_type_function.py

name = "xnocode"
age = 35
PI = 3.14
 
isPrime = True
isNone = None
 
print(type(PI))
print(type(name))
print(type(age))
print(type(isPrime))
print(type(isNone))

output

<class 'float'>
<class 'str'>
<class 'int'>
<class 'bool'>
<class 'NoneType'>

Note

type() returns the data type of a variable.

<< Python Data Types | Python Keywords >>