http://learnpythonthehardway.org/book/ex4.html
There’s an extra credit question asking me to explain why the floating-point 4.0 is used instead of 4.
I understand that a floating point is used for accuracy, but I can’t fathom why it is necessary in any case in this example.
There doesn’t actually seem to be any need for a float instead of an int in that particular example. It could have an effect if you were to divide something by it, but that’s not happening here. (And even then, it’d depend on whether you were using Python 2 or 3, as float division is the default in 3).
If you look at the comments below, zedshaw (the author) admits as much: