Programming Tutorial for absolute beginners
Clodoaldo Pinto
clodoaldo.pinto at gmail.com
Sun Apr 9 08:20:06 EDT 2006
Duncan Smith wrote:
>
> But as you use conversions to float in order to avoid integer division
> in your code examples, it might be best to explain what's going on, even
> if you do have to explain the relevant types.
>
I changed the comments in the first program that uses float() to:
# The raw_input() function asks the user for a text
# As a text can't be multiplied or divided the
# float() function tranforms the text into a decimal number
>
> I can't imagine anyone (who doesn't already know) looking at the example
> and not wondering why it returned 1 rather than something else.
>
...
>
> Integer is more mathematical, and more precise. I just looked up some
> definitions for "whole number", and found it can apparently mean
> positive integer, non-negative integer, or integer. Maybe you can use
> integer and just put "whole number" in brackets after it, the first time
> you use it; as a vague definition? But describing the relevant types
> and integer division might make your later examples clearer.
>
Now it says "integer (whole number)" followed by a link to a forum post
where this issue can be discussed.
http://programming-crash-course.com/integer_versus_float_division
Regards, Clodoaldo
More information about the Python-list
mailing list