Return value of type(type) in Python

Python type() function example: Here, we are going to learn about the type() function in Python. By IncludeHelp Last updated : September 18, 2023

Given a statement type(type) – we have to print its return type value.

Python type() function

The 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)

The type is also a class of type, the statement type(type)) returns "type".

Return value of type(type(int))

The type(int) returns <class 'str'> and the statement type(<class 'str'>) returns "type".

Python program 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

The output of the above program is:

<class 'str'>
<class 'int'>
<class 'float'>
<class 'type'>
<class 'type'>
<class 'type'>
<class 'type'>
<class 'type'>

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.