Overview:
- The Python built-in function type() returns the type of an object.
- The type of an object is represented as an object of class type.
- In a Python program, each variable and each literal is an instance of some class. In the statement x = 1, x is an instance of class int.
- Python is a strongly typed programming language. The type of an object determines the operations available on an object.
- Python is also a dynamically typed language, hence no declaration of type is required when a variable is introduced in a scope. The type of a variable can be changed during the execution of the program by assigning objects of diffrent types as the program runs.
Example:
# Example Python program that uses # Print the type of numeric values... # A float # Print the type of few collections... # A list # Dictionary # Print the type of a Python type |