Question #210106

How do you convert between the different python data types? What data quality issues arise when converting data types?


Expert's answer

You can change the data type as follows:

a = 10

b = str(a) # b = " 10"


But when converting, the following problems may arise:

a = 10.3

b = int (a) # b = 10

Thus, we lose in accuracy


Or when trying to convert:

a = 'fg'

b = float (a) # Value Error: could not convert string to float: 'fg'

Some data types cannot be converted to others


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS