Menu Close

Python isinstance() Function

In this article, we are going to learn all about the Python isinstance() method to check a specified object is of the specified type or not. isinstance method in python return only Boolean value that means True or False.

In the previous tutorial, we have seen all about the Python input function to ask input from the users.

Python isinstance function

Python isinstance() function is a built-in function in Python that returns True if the specified object is of the specified type.
If the type parameter is a tuple, this function will return True if the objects one of the types in the tuple.


The syntax of isinstance function in Python is:-

isinstance(object, type)


isinstance function accepts two parameter.

  • object:- Required, An object.
  • type:- A type or class, A tuple of classes or types.

Return Value

The return Value of python isinstance() function is only Boolean value True or False.

Python isinstance() examples

Here we will take some examples to understand python isinstance() function.

Example 1:

print(isinstance(5, int))
print(isinstance('Programming Funda', str))
print(isinstance(12.21, float))
print(isinstance([1, 2, 3, 4], list))
print(isinstance((1, 2, 3, 4), tuple))
print(isinstance({1, 2, 3, 4, 5}, set))



Example 2:

class Person:
	name = 'Programming Funda'
	def __init__(self):
		print(f"My name is {}.")

#create instance of the class Person.	
p1 = Person()
print(isinstance(p1, Person))


My name is Programming Funda.


In this article, you have learned all about the Python isinstance function to check a specified object is of the specified type or not. This function returns one boolean value that means True or False.

If you like this article, please share and keep visiting for further python built-in functions tutorials.

Python built-in functions

For more information:- Click Here

Previous Article
Next Article

Related Posts

Leave a Reply