Javatpoint Logo
Javatpoint Logo

Python type() Function

Python type() returns the type of the specified object if a single argument is passed to the type(). If three arguments are passed, it returns a new type of object.

Signature

Parameters

object: The type() returns the type of this object if one parameter is specified.

bases (optional): It specifies the base classes.

dict (optional): It specifies the namespace with the definition for the class.

Return

It returns the type of the specified object if a single argument is passed to the type(). If three arguments are passed, it returns a new type of object.

Python type() Function Example 1

The below example shows how to get the type of an object.

Output:

<class 'list'>
<class 'dict'>
<class '__main__.Python'>

Explanation: In the above example, we have taken a List that contains some values, and in return, it prints the type of the List.

In the second case, we have taken a Dict that contains some values, and in return, it prints the type of the Dict.

Then, we have defined a class named as Python and produced an InstanceOfPython which prints its type.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA