demo_numbers_convert.py:
#convert from int to float: x = float(1) #convert from float to int: y = int(2.8) #convert from int to complex: z = complex(x) print(x) print(y) print(z)
➜ begtut>python demo_numbers_convert.py
1.0
2
(1+0j)
<class 'float'> <class 'int'> <class 'complex'>