Re: Numbers in python

2006-03-10 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> However, I can't seem to get the program to treat the numbers as >> numbers. If I put them in the dictionary as 'THE' = int(0.965) the >> program returns 1.0 > >It certainoly does _not_ return 1.0 - it returns 1. And tha

Re: Numbers in python

2006-03-10 Thread Steve Holden
[EMAIL PROTECTED] wrote: > 'It certainoly does _not_ return 1.0 - it returns 1. And that is all it > can > return for being an integer that has by definition no fractional part. > ' > > For goodness sake, it was a typo, I'm so sorry! > Guess that's what you get for calling yourself "brainy_muppet

Re: Numbers in python

2006-03-10 Thread neildunn
If your still worried by using floats for your values you may wish to look into the decimal module: http://docs.python.org/lib/module-decimal.html Example: >>> from decimal import Decimal >>> Decimal(2) + Decimal('1.47') Decimal("3.47") Regards, Neil -- http://mail.python.org/mailman/listinf

Re: Numbers in python

2006-03-10 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > if I put 'THE' = float(0.965) it returns 0.9655549 or something > similar. That's for the same reasons as you can't write 1/3rd in decimal notation. Computers can't write 1/10th in binary notation. Sybren -- The problem with the world is stupidity. No

Re: Numbers in python

2006-03-10 Thread brainy_muppet
'It certainoly does _not_ return 1.0 - it returns 1. And that is all it can return for being an integer that has by definition no fractional part. ' For goodness sake, it was a typo, I'm so sorry! -- http://mail.python.org/mailman/listinfo/python-list

Re: Numbers in python

2006-03-10 Thread Diez B. Roggisch
> It certainoly does _not_ return 1.0 - it returns 1. And that is all it can > return for being an integer that has by definition no fractional part. Duncan was right of course. It returns 0. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Numbers in python

2006-03-10 Thread brainy_muppet
'It certainoly does _not_ return 1.0 - it returns 1. And that is all it can return for being an integer that has by definition no fractional part. ' For goodness sake, it was a typo, I'm so sorry! -- http://mail.python.org/mailman/listinfo/python-list

Re: Numbers in python

2006-03-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Basically, I have a code with is almost finished but I've having > difficultly with the last stage of the process. I have a program that > gets assigns different words with a different value via looking them up > in a dictionary: > > eg if THE is in the writing, it assig

Re: Numbers in python

2006-03-10 Thread Duncan Booth
wrote: > If I put them in the dictionary as 'THE' = int(0.965) the > program returns 1.0 and if I put 'THE' = float(0.965) it returns > 0.9655549 or something similar. Neither of these are right! Your system seems to be really screwed. int(0.965) should be 0, and float(0.965) should be 0.96

Re: Numbers in python

2006-03-10 Thread Diez B. Roggisch
> However, I can't seem to get the program to treat the numbers as > numbers. If I put them in the dictionary as 'THE' = int(0.965) the > program returns 1.0 It certainoly does _not_ return 1.0 - it returns 1. And that is all it can return for being an integer that has by definition no fractional