Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Richard D. Moores
On Thu, Jul 1, 2010 at 16:18, Steven D'Aprano wrote: > On Fri, 2 Jul 2010 05:18:00 am Eike Welk wrote: > >> As you are using long integers (and you were previously writing about >> prime numbers) the precision of floating point numbers might not be >> enough for your purposes. > > It certainly won

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Steven D'Aprano
On Fri, 2 Jul 2010 05:18:00 am Eike Welk wrote: > As you are using long integers (and you were previously writing about > prime numbers) the precision of floating point numbers might not be > enough for your purposes. It certainly won't be once you get to large enough primes! > Therefore you sho

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Richard D. Moores
On Thu, Jul 1, 2010 at 12:18, Eike Welk wrote: > Therefore you should probably use the integer division operator: "//" >>> x = 200033 >>> x//2 100016 I can live with THAT error! Thanks, Eike! But I will press on with Mark

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Mark Lawrence
On 01/07/2010 20:18, Eike Welk wrote: Hello Richard! On Thursday July 1 2010 15:11:21 Richard D. Moores wrote: Thanks to yours and others responses, I've learned some things I didn't know, but remember, I'm starting with long ints such as Also note that in Python 3 the "/" (division) operator

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Eike Welk
Hello Richard! On Thursday July 1 2010 15:11:21 Richard D. Moores wrote: > Thanks to yours and others responses, I've learned some things I > didn't know, but remember, I'm starting with long ints such as Also note that in Python 3 the "/" (division) operator returns a floating point number when

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Richard D. Moores
On Thu, Jul 1, 2010 at 09:25, Mark Lawrence wrote: > Take a look at section 7.1.3 here. > > http://docs.python.org/py3k/library/string.html#string-formatting > > This is the recommended way to format strings in Python 3. Thanks, Mark. Looks good, if cryptic. I don't have time to dig into it now

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Mark Lawrence
On 01/07/2010 14:11, Richard D. Moores wrote: On Thu, Jul 1, 2010 at 04:57, Steven D'Aprano wrote: On Thu, 1 Jul 2010 06:26:21 pm Richard D. Moores wrote: x = 2034 x/2 1017.0 print(x/2) 1e+15 I was expecting, in fact needing, 117 or 1000

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Richard D. Moores
On Thu, Jul 1, 2010 at 04:57, Steven D'Aprano wrote: > On Thu, 1 Jul 2010 06:26:21 pm Richard D. Moores wrote: >> >>> x = 2034 >> >>> x/2 >> 1017.0 >> >> >>> print(x/2) >> 1e+15 >> >> I was expecting, in fact needing, 117 or >> 117.0 >> >> 1e

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Steven D'Aprano
On Thu, 1 Jul 2010 06:26:21 pm Richard D. Moores wrote: > >>> x = 2034 > >>> x/2 > 1017.0 > > >>> print(x/2) > 1e+15 > > I was expecting, in fact needing, 117 or > 117.0 > > 1e+15 is unsatisfactory. Am I forced to use the decimal module? This

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Evert Rol
x = 2034 x/2 > 1017.0 print(x/2) > 1e+15 > > I was expecting, in fact needing, 117 or 117.0 > > 1e+15 is unsatisfactory. Am I forced to use the decimal module? Can't you use string formatting? Eg: >>> print("{0:15.0f}".format

Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Shantanoo
without using decimal module: >>> x = 2034 >>> print('%d'%(x/2)) 1017 On Thu, Jul 1, 2010 at 13:56, Richard D. Moores wrote: x = 2034 x/2 > 1017.0 print(x/2) > 1e+15 > > I was expecting, in fact needing, 117 or 1

[Tutor] puzzled by Python 3's print()

2010-07-01 Thread Richard D. Moores
>>> x = 2034 >>> x/2 1017.0 >>> print(x/2) 1e+15 I was expecting, in fact needing, 117 or 117.0 1e+15 is unsatisfactory. Am I forced to use the decimal module? Dick Moores ___ Tutor maillist - T