Learn Python in 7 Days
上QQ阅读APP看书,第一时间看更新

Type conversions

It is easy to convert the data type of operands using a type conversion function. Let's understand with some examples:

In the preceding screenshot, 4.77 is converted into 4. In order to convert 4.77 into the int data type, the int() function is used. Likewise, if you want to convert into float, use the float() function.