Home »
Python
Return value of type(type) in Python
Python type() function example: Here, we are going to learn about the type() function in Python.
Submitted by IncludeHelp, on March 31, 2019
Given a statement type(type) – we have to print its return type value.
Python type() function
type() function is a library function in Python, it is used to get the type of the value/data type. It accepts an argument returns the class of the argument the object belongs to.
Syntax:
type(value/variable/type)
Return value of type(type):
type is also a class of type, the statement type(type)) returns "type".
Return value of type(type(int)):
type(int) returns <class 'str'> and the statement type(<class 'str'>) returns "type".
Python code to demonstrate example of type() function
# python code to demonstrate example of
# type() function
# printing types of various types of values
print(type('Hello'))
print(type(10))
print(type(10.23))
print(type(type))
print(type(type(int)))
print(type(type(str)))
print(type(type(10)))
print(type(type('Hello')))
Output
<class 'str'>
<class 'int'>
<class 'float'>
<class 'type'>
<class 'type'>
<class 'type'>
<class 'type'>
<class 'type'>
TOP Interview Coding Problems/Challenges