python cast data type code example
Example 1: how to convert types of variablesin python
int(anyData)
str(anyData)
ord(chr)
hex(int)
oct(int)
float(anyData)
tuple()
set()
list()
dict()
complex(real,imag)
Example 2: python data type conversion
equationStrToInt = '8 * 8'
eval(equationStrToInt)
type(equationStrToInt)
print(equationStrToInt)
strToList = 'GREPPER'
list(strToList)
type(strToList)
print(strToList)
Example 3: how to tyoecast in python
example = 1.3234325
print(type(example))
Example 4: cast as float python
not_float = '.0975'
is_float = .0986
print(not_float)
print(is_float)
new_number = float(not_float) + is_float
print(new_number)