What is the usage of the typeof function in Python?
In Python, the type() function is used to return the type of an object. Here is the syntax:
type(object)
In this case, the object is the object from which to obtain the type. For example:
num = 10
print(type(num)) # <class 'int'>
string = "Hello"
print(type(string)) # <class 'str'>
lst = [1, 2, 3]
print(type(lst)) # <class 'list'>
dict = {"name": "Alice", "age": 30}
print(type(dict)) # <class 'dict'>
The type() function can be used to check the type of an instance or use it for flow control.