Floating point calculation problem

Chris Angelico rosuav at gmail.com
Sat Feb 2 06:38:55 EST 2013


On Sat, Feb 2, 2013 at 10:34 PM, Schizoid Man <schiz_man at 21stcentury.com> wrote:
>> raw_input() takes a line from the keyboard (handwave) and returns it
>> as a string.
>>
>> input() in 2.X takes a line from the keyboard and evaluates it as a
>> Python expression.
>>
>> float() takes a string, float, int, etc, and returns the
>> nearest-equivalent floating point value.
>>
>> What's the input you're giving to it?
>
>
> Something simple like 3.0.

If your input has no decimal point in it, eval (or input) will return
an integer, not a float. Other than that, I can't see any obvious
reason for there to be a difference. Can you put together a simple
script that demonstrates the problem and post it, along with the exact
input that you're giving it, and the different outputs?

Chris Angelico



More information about the Python-list mailing list