In this article, we understand the type conversion with the example.
Pre knowledge is required to learn type conversion, so make sure you know the type of data types in python.
What is Type Conversion?
- Implicit Type Conversion
- Explicit Type Conversion
Implicit Type Conversion
Explanation of the above program:
- In the above program first, we take two-variable num1 and num2.
- Where num1 we store 10 and num2 we store 10.5
- Now we make another variable num3 and store the value of num1+num2
- And then we print the data types of all the variables, num1, num2 and num3
- num3 converted in the float because python always converts the lower data types to higher data types because to prevent the loss of data.