From: monkeys paw on 6 Apr 2010 23:16 I have the following acre meter which works for integers, how do i convert this to float? I tried return float ((208.0 * 208.0) * n) >>> def s(n): .... return lambda x: (208 * 208) * n .... >>> f = s(1) >>> f(1) 43264 >>> 208 * 208 43264 >>> f(.25) 43264
From: Patrick Maupin on 7 Apr 2010 00:04 On Apr 6, 10:16 pm, monkeys paw <mon...(a)joemoney.net> wrote: > I have the following acre meter which works for integers, > how do i convert this to float? I tried > > return float ((208.0 * 208.0) * n) > > >>> def s(n): > ... return lambda x: (208 * 208) * n > ... > >>> f = s(1) > >>> f(1) > 43264 > >>> 208 * 208 > 43264 > >>> f(.25) > 43264 Not sure why you are returning a lambda (which is just a function that does not have a name) from an outer function. A function that does this multiplication would simply be: def s(n): return 208.0 * 208.0 * n Regards, Pat
From: Patrick Maupin on 7 Apr 2010 00:10 On Apr 6, 11:04 pm, Patrick Maupin <pmau...(a)gmail.com> wrote: > On Apr 6, 10:16 pm, monkeys paw <mon...(a)joemoney.net> wrote: > > > I have the following acre meter which works for integers, > > how do i convert this to float? I tried > > > return float ((208.0 * 208.0) * n) > > > >>> def s(n): > > ... return lambda x: (208 * 208) * n > > ... > > >>> f = s(1) > > >>> f(1) > > 43264 > > >>> 208 * 208 > > 43264 > > >>> f(.25) > > 43264 > > Not sure why you are returning a lambda (which is just a function that > does not have a name) from an outer function. > > A function that does this multiplication would simply be: > > def s(n): > return 208.0 * 208.0 * n > > Regards, > Pat I realized I didn't show the use. A bit different than what you were doing: >>> def s(n): .... return 208.0 * 208.0 * n .... >>> s(1) 43264.0 >>> s(0.5) 21632.0 >>> s(3) 129792.0 I'm not sure exactly what you mean by "acre meter" though; this returns the number of square feet in 'n' acres. Regards, Pat
From: Patrick Maupin on 7 Apr 2010 00:15 On Apr 6, 11:10 pm, Patrick Maupin <pmau...(a)gmail.com> wrote: > On Apr 6, 11:04 pm, Patrick Maupin <pmau...(a)gmail.com> wrote: > > > > > On Apr 6, 10:16 pm, monkeys paw <mon...(a)joemoney.net> wrote: > > > > I have the following acre meter which works for integers, > > > how do i convert this to float? I tried > > > > return float ((208.0 * 208.0) * n) > > > > >>> def s(n): > > > ... return lambda x: (208 * 208) * n > > > ... > > > >>> f = s(1) > > > >>> f(1) > > > 43264 > > > >>> 208 * 208 > > > 43264 > > > >>> f(.25) > > > 43264 > > > Not sure why you are returning a lambda (which is just a function that > > does not have a name) from an outer function. > > > A function that does this multiplication would simply be: > > > def s(n): > > return 208.0 * 208.0 * n > > > Regards, > > Pat > > I realized I didn't show the use. A bit different than what you were > doing: > > >>> def s(n): > > ... return 208.0 * 208.0 * n > ...>>> s(1) > 43264.0 > >>> s(0.5) > 21632.0 > >>> s(3) > > 129792.0 > > I'm not sure exactly what you mean by "acre meter" though; this > returns the number of square feet in 'n' acres. > > Regards, > Pat I should stop making a habit of responding to myself, BUT. This isn't quite an acre in square feet. I just saw the 43xxx and assumed it was, and then realized it couldn't be, because it wasn't divisible by 10. (I used to measure land with my grandfather with a 66 foot long chain, and learned at an early age that an acre was 1 chain by 10 chains, or 66 * 66 * 10 = 43560 sqft.) That's an exact number, and 208 is a poor approximation of its square root. Regards, Pat
From: Peter Pearson on 7 Apr 2010 13:08
On Tue, 06 Apr 2010 23:16:18 -0400, monkeys paw <monkey(a)joemoney.net> wrote: > I have the following acre meter which works for integers, > how do i convert this to float? I tried > > return float ((208.0 * 208.0) * n) > > >>> def s(n): > ... return lambda x: (208 * 208) * n > ... > >>> f = s(1) > >>> f(1) > 43264 > >>> 208 * 208 > 43264 > >>> f(.25) > 43264 The expression "lambda x: (208 * 208) * n" is independent of x. Is that what you intended? -- To email me, substitute nowhere->spamcop, invalid->net. |