Session - 3
Session - 3
Literals
• string = "15"
• number = 7
• string_number = int(string) #throws an error if the
string is not a valid integer
• sum= number + string_number
• print("The Sum of both the numbers is: ", sum)
• ### Output:
```
• The Sum of both the numbers is 22
2-Implicit type casting:
• Data types in Python do not have the same level i.e. ordering of
data types is not the same in Python.
• Some of the data types have higher-order, and some have lower
order.
• While performing any operations on variables with different data
types in Python, one of the variable's data types will be changed
to the higher data type.
• According to the level, one data type is converted into other by
the Python interpreter itself (automatically). This is called,
implicit typecasting in python.
Example of implicit type casting: