Type Conversion
Python Type Conversion
Type Conversion is a process of converting value of one datatype to another datatype.
There could be many scenarios where we need to convert data from type to another. For example, consider a simple use case of where we need to read two numbers from user and perform addition. We can read only string from user via console. And, we need to convert this string value to an integer of floating-point number.
The following list of tutorials cover use-cases of converting values from one datatype to another.
Converting from int to other types in Python
In the following tutorials, we convert value of int type to other datatypes with well detailed examples.
Converting from float to other types in Python
In the following tutorials, we convert value of float type to other datatypes.
Converting from string to other types in Python
In the following tutorials, we convert value of string type to other datatypes.
Converting between numeric representations in Python
In the following tutorials, we convert between numeric value representations.
- Python - Convert decimal to hex
- This tutorial covers examples to convert a given decimal number to a hexadecimal number using hex() function.
- Python - Convert hex to decimal
- This tutorial covers examples to convert a given hexadecimal number to a decimal number using int() function.
Converting from list to other types in Python
In the following tutorials, we convert object of list type to other types.
Converting from tuple to other types in Python
In the following tutorials, we convert object of tuple type to other types.
Converting from set to other types in Python
In the following tutorials, we convert object of set type to other types.
Converting from range to other types in Python
In the following tutorials, we convert object of range type to other types.
- Python - Convert range to a list
- This tutorial convert examples to convert a given range of numbers into a list object using list() builtin function.
- Python - Convert numeric string range to a list
- This tutorial teaches us to convert numeric string range like
'4-9'
to a list like[4, 5, 6, 7, 8, 9]
.