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 of one datatype to another.
- Convert Int to FloatThis tutorial covers examples to convert given integer value to a floating-point number using float() function.
- Convert Int to Complex NumberThis tutorial covers examples to convert given integer value to a complex number using complex() function.
- Convert Int to StringThis tutorial covers examples to convert given integer value to a string using str() function.
- Convert Float to IntThis tutorial covers examples to convert given floating-point value to an integer using int() function.
- Convert Float to ComplexThis tutorial covers examples to convert given floating-point value to a complex number using complex() function.
- Convert Float to StringThis tutorial covers examples to convert given floating-point value to a string using str() function.
- Convert String to IntegerThis tutorial convert examples to convert given string value to an integer using int() function.
- Convert String to FloatThis tutorial convert examples to convert given string value to a floating-point number using float() function.
- Convert Decimal to HexThis tutorial covers examples to convert a given decimal number to a hexadecimal number using hex() function.
- Convert Hex to DecimalThis tutorial covers examples to convert a given hexadecimal number to a decimal number using int() function.
- Convert List to StringThis tutorial convert examples to convert a list of elements to a string using String.join() function.
- Convert List to TupleThis tutorial convert examples to convert a given list of elements into a tuple using tuple() function, or unpacking technique.
- Convert List to SetThis tutorial convert examples to convert a given list of elements into a set using set() function, or unpacking technique.
- Convert Tuple to ListThis tutorial convert examples to convert a given list of elements into a tuple using list() function, or List Comprehension.
- Convert Tuple to SetThis tutorial convert examples to convert a given tuple of elements into a set using set() function, or unpacking technique.
- Convert Set to ListThis tutorial convert examples to convert a given set of elements into a list using list() function, or List Comprehension.
- Convert Set to TupleThis tutorial convert examples to convert a given set of elements into a tuple using tuple() function, or unpacking technique.
- Convert Range to a ListThis tutorial convert examples to convert a given range of numbers into a list object using list() builtin function.
- Convert Numeric String Range to a ListThis tutorial teaches us to convert numeric string range like
'4-9'
to a list like[4, 5, 6, 7, 8, 9]
.