Re: Function error

2014-06-14 Thread Terry Reedy
On 6/14/2014 2:17 PM, sandhyaranimangip...@gmail.com wrote: I am new to python, pls help me to resolve the below error Please read the nice tutorial, though no necessarily all at once. It explains things like this. def fib(n): ... """Print a Fibonacci series up to n.""" File "", line 2

Re: Function error

2014-06-14 Thread John Ladasky
On Saturday, June 14, 2014 11:17:50 AM UTC-7, sandhyaran...@gmail.com wrote: > I am new to python, pls help me to resolve the below error > > > > > > >>> def fib(n): > > ... """Print a Fibonacci series up to n.""" > > File "", line 2 > > """Print a Fibonacci series up to n.""" > >

Function error

2014-06-14 Thread sandhyaranimangipudi
I am new to python, pls help me to resolve the below error >>> def fib(n): ... """Print a Fibonacci series up to n.""" File "", line 2 """Print a Fibonacci series up to n.""" ^ IndentationError: expected an indented block -- https://mail.python.org

Re: round function error???

2008-07-20 Thread John Machin
On Jul 21, 12:56 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > On Jul 19, 12:20 am, John Machin <[EMAIL PROTECTED]> wrote: > > > On Jul 19, 8:05 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > > for more information. But I'm guessing that you're > > > questioning the fact that a value that's a

Re: round function error???

2008-07-20 Thread Mark Dickinson
On Jul 19, 12:20 am, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 19, 8:05 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > for more information.  But I'm guessing that you're > > questioning the fact that a value that's apparently > > *less* than 3499.35 is rounded up to 3499.4, rather > > tha

Re: round function error???

2008-07-18 Thread John Machin
On Jul 19, 8:05 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > On Jul 18, 10:17 pm, Anthony <[EMAIL PROTECTED]> wrote: > > > Isn't this a mistake??? > > Which 'this'? That is, what were you expecting? > > If you're objecting to the fact that the second result > produces 3499.34999 instead

Re: round function error???

2008-07-18 Thread Mark Dickinson
On Jul 18, 11:15 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > No, round() return binary floats that, in general, cannot represent > decimal floats exactly.  Formatted printing gives what you expect. >  >>> '%8.2f' % x > ' 3499.35' Sure. But it's still true that the second printed value (printed a

Re: round function error???

2008-07-18 Thread Terry Reedy
Anthony wrote: Isn't this a mistake??? round(3499.349439034,44) 3499.3494390340002 round(_,2) 3499.34999 round(_,1) 3499.40001 My Python 2.5.1 spat that out.. No, round() return binary floats that, in general, cannot represent decimal floats exactly. Formatted printi

Re: round function error???

2008-07-18 Thread Mark Dickinson
On Jul 18, 10:17 pm, Anthony <[EMAIL PROTECTED]> wrote: > Isn't this a mistake??? Which 'this'? That is, what were you expecting? If you're objecting to the fact that the second result produces 3499.34999 instead of 3499.35, then no, that's not a mistake; see http://www.python.org/doc/

round function error???

2008-07-18 Thread Anthony
Isn't this a mistake??? >>> round(3499.349439034,44) 3499.3494390340002 >>> round(_,2) 3499.34999 >>> round(_,1) 3499.40001 My Python 2.5.1 spat that out.. -- http://mail.python.org/mailman/listinfo/python-list

Re: 2004 example, passing function error

2008-05-13 Thread alex23
On May 14, 11:40 am, globalrev <[EMAIL PROTECTED]> wrote: > so just a mistake on his part? but it looks like he just copied his > shell...has there been a change since 2004 inr egards to how you can > pass functions as arguments to functions?? Adding the value argument (x) to the compose function

Re: 2004 example, passing function error

2008-05-13 Thread Carsten Haese
globalrev wrote: but it looks like he just copied his shell...has there been a change since 2004 inr egards to how you can pass functions as arguments to functions?? It looks like it's copy/pasted from a shell, but it's not. No past or present Python interpreter could produce an interactive s

2004 example, passing function error

2008-05-13 Thread globalrev
http://linuxgazette.net/109/pramode.html >>> >>>def sqr(x): return x*x ... >>>def cube(x): return x*x*x ... >>>sqr >>>a = [sqr, cube] >>>a[0](2) >>>def compose(f, g): return f(g(x)) ... >>>compose(sqr, cube, 2) 64 >>> but i get: >>> compose(sqr, cube, 2) Traceback (most recent call last): F