Форум сайта python.su
0
пишу:
pi = 3.14 s = pi + 2 l = len(str(s)) print("pi =", pi, ",", "s =", s, l)
3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31)
Python Type “help”, “copyright”, “credits” or “license” for more information.
pi = 3.14 , s = 5.140000000000001 17
Офлайн
568
Офлайн
3
уже отвечали тут http://python.su/forum/topic/26534/
It’s important to realize that this is, in a real sense, an illusion: the value in the machine is not exactly 1/10, you’re simply rounding the display of the true machine value. This fact becomes apparent as soon as you try to do arithmetic with these values
>>> 0.1 + 0.2
0.30000000000000004
ну и значение Pi можно брать из модуля math, math.pi
Офлайн