types of conversion in python code example
Example 1: python data type conversion
equationStrToInt = '8 * 8'
eval(equationStrToInt)
type(equationStrToInt)
print(equationStrToInt)
strToList = 'GREPPER'
list(strToList)
type(strToList)
print(strToList)
Example 2: typecasting inpython
>>> string = '123'
>>> type(string)
<class 'str'>
>>> integer = int(string)
>>> type(integer)
<class 'int'>
>>> float_number = float(integer)
>>> type(float_number)
<class 'float'>
>>> string, integer, float_number
('123', 123, 123.0)