Question -
Answer -
Yes, Python supportdata type conversion. To convert between built-in types, programmer simply usethe type name as a function. There are several built-in functions to performconversion from one data type to another. These functions return a new objectrepresting the converted value.
Function | Description |
int (x [, base]) | Converts x to an integer, base specifies the base if x is a string. |
long [x [, base]) | Converts x to a long integer, base specifies the base if x is a string. |
float (x) | Converts x to a floatingpoint number. |
complex (real, [ing]) | Creates a complex number. |
str (x) | Converts object x to a string representation. |
repr (x) | Converts object x to an expression string. |
tuple (x) | Converts x to a tuple. |
list (x) | Converts x to a list. |
chr (x) | Convets an integer to a character. |
unichr (x) | Converts an integer to a Unicode character. |
diet (x) | Creates a disetionary, x must be a sequence of tuples. |
set (x) | Converts x to a set |