Determine the type of an object?

To determine the type of an object in Python, you can use the type function. For example:

x = 5
print(type(x))   # Output: <class 'int'>

y = "hello"
print(type(y))   # Output: <class 'str'>

Watch a course Python - The Practical Guide

You can also use the isinstance function to check if an object is an instance of a particular class or a subclass of that class. For example:

x = 5
print(isinstance(x, int))   # Output: True
print(isinstance(x, str))   # Output: False

y = "hello"
print(isinstance(y, str))   # Output: True