Python type() function
Syntax:
type(object)
Example:
Input:
b = 10.23
c = "Hello"
# Function call
print("type(b): ", type(b))
print("type(c): ", type(c))
Output:
type(b): <class 'float'>
type(c): <class 'str'>
Python code for determining the type of objects
a = 10
b = 10.23
c = "Hello"
d = (10, 20, 30, 40)
e = [10, 20, 30, 40]
# printing types of the objects
# using type() function
print("type(a): ", type(a))
print("type(b): ", type(b))
print("type(c): ", type(c))
print("type(d): ", type(d))
print("type(e): ", type(e))
# printing the type of the value
# using type() function
print("type(10): ", type(10))
print("type(10.23): ", type(10.23))
print("type(\"Hello\"): ", type("Hello"))
print("type((10, 20, 30, 40)): ", type((10, 20, 30, 40)))
print("type([10, 20, 30, 40]): ", type([10, 20, 30, 40]))
Output