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'>





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.