Re: Exercise 3: Numbers And Math — Learn Python The Hard Way, 2nd Edition - http://learnpythonthehardway.org/book...
"if you type in just one of the numbers in a function as a floating point, you can get different results depending on which one is the floating point. For example, you can test via python that the following two lines produce different results print 25 + 30 / 7.0 print 25.0 + 30 / 7 This is because the order of execution (in this case, division before addition) controls when the Decimal Arithmetic gets converted to Floating Point - In one case python uses Floating Point Arithmetic for 30.0 / 7, which results in 4.28571428571, but in the other, it uses Decimal Arithmetic for 30 / 7, which results in 4. 25 + 4.28571428571 ==> 29.2857142857 25.0 + 4 ===> 29.0 Bear in mind that this is not a python problem, it is a Decimal v Floating Point problem and is common to a lot of computer languages (although some deal with it better than others)" - martin english