Unlike most other programming languages, in Python, when you declare a variable you do not specify its type. For example, the following statement typed on the Python console creates a variable called value with an initial value of 5. The data type of value becomes implicity int.
Python provides type function that allows you to determine the type of a given variable. You would determine the type of above value variable using the statement:
This will print the following output on the console:
The type of the variable is represented by a class in Python. So the output shows the data type as class of a certain type. You will learn the class in Python in further lessons.
Now, just the way you declare an integer variable, you can also declare a complex variable. The following statement declares a complex variable.
You can check its type using the type function:
As you see, it prints the class as complex which is another built-in class in Python.
Try it Yourself!