Hello I am using a dictionary in Python storing some cities and their population like that:
population = { 'Shanghai' : 17.8, 'Istanbul' : 13.3, 'Karachi' : 13.0, 'mumbai' : 12.5 }
Now if I use the command print population
, I get the result:
{'Karachi': 13.0, 'Shanghai': 17.800000000000001, 'Istanbul': 13.300000000000001, 'mumbai': 12.5}
whereas if I use the command print population['Shanghai']
I get the initial input of 17.8
.
My question to you is how does the 17.8
and the 13.3
turned into 17.800000000000001
and 13.300000000000001
respectively? How was all that information produced? And why is it stored there, since my initial input denotes that I do not need that extra information, at least as far as I know.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…