Re: [Tutor] How inefficient is this code?

2014-05-08 Thread Joe Cortes
Welcome to the wonderful world of generators! Looking at your code, you'll notice two things. First, you're iterating over all the numbers twice: once to calculate them, and then another time to actually do the sum. What's worse, at any given point in time, you're only really using fibs[-1] and fi

[Tutor] (no subject)

2014-05-08 Thread Kevin Johnson
Hi, Total beginner to python and am working my way through Michael Dawsons 'Absolute beginner' book. Just got stuck on the last bit of the challenges from chapter 3. Essentially need to create a game where the user picks a number between 1 and 100 and the computer has to guess, program should indi

Re: [Tutor] How inefficient is this code?

2014-05-08 Thread Joe Cortes
> I see. Thanks that is exactly what I was looking for. Would your > example be an instance of an object-oriented approach, > compartmentalizing things into functions? That's an interesting question. It's an example of abstraction, which is one of the pillars of object oriented design. You're abs

Re: [Tutor] (no subject) - (added) Number guessing game

2014-05-08 Thread Jay Lozier
On 05/08/2014 06:00 AM, Kevin Johnson wrote: Hi, Total beginner to python and am working my way through Michael Dawsons 'Absolute beginner' book. Just got stuck on the last bit of the challenges from chapt

Re: [Tutor] Final review

2014-05-08 Thread Steven D'Aprano
On Wed, May 07, 2014 at 08:49:11PM -0700, Scott W Dunning wrote: [...] > > >>> greeting [len(greeting)] > > > > It is trying to access the character at the position "11", where the > > string "Hello world" doesn't contain any value in the index "11" and > > the maximum index is 10. So it throws

Re: [Tutor] (no subject)

2014-05-08 Thread Alan Gauld
On 08/05/14 11:00, Kevin Johnson wrote: user picks a number between 1 and 100 and the computer has to guess, Hmm, usually its the other way around, the computer picks a number and the user guesses it. Interesting twist! The highlighted bit is where I think I'm going wrong but I just can't t

Re: [Tutor] (no subject)

2014-05-08 Thread Steven D'Aprano
Hello Kevin, and welcome! My responses are below, interleaved between yours. On Thu, May 08, 2014 at 10:00:11AM +, Kevin Johnson wrote: > Hi, > > Total beginner to python and am working my way through Michael Dawsons > 'Absolute beginner' book. Just got stuck on the last bit of the challenge

Re: [Tutor] How inefficient is this code?

2014-05-08 Thread Neil D. Cerutti
On 5/7/2014 8:39 PM, C Smith wrote: I see. Thanks that is exactly what I was looking for. Would your example be an instance of an object-oriented approach, compartmentalizing things into functions? One of the fun parts of Project Euler is using mathematical analysis and other tricks to improve

Re: [Tutor] PyCountry currency formatting woes

2014-05-08 Thread Sithembewena Lloyd Dube
Thank you all, babel works just fine. I also tried ccy, which isn't bad either - except that it returns non-unicode currency letters for countries in the Eurozone. On Mon, May 5, 2014 at 10:10 AM, Peter Otten <__pete...@web.de> wrote: > Sithembewena Lloyd Dube wrote: > > > Thanks, i was actually

[Tutor] preferred httprequest library

2014-05-08 Thread Palmer, Eric
Sorry, I¹m sure this has been asked before: I¹m new to python but not so much to programming. I need to construct a set or programs to test a forms poster that has been enhanced (it is in php). I mostly need http get and post. This is a hands on set of tests and does not have to be bullet proof

Re: [Tutor] preferred httprequest library

2014-05-08 Thread Martin A. Brown
Hello, : I¹m new to python but not so much to programming. I need to : construct a set or programs to test a forms poster that has been : enhanced (it is in php). I mostly need http get and post. This : is a hands on set of tests and does not have to be bullet proof. : : What would b

Re: [Tutor] Tutor Digest, Vol 123, Issue 27

2014-05-08 Thread Kevin Johnson
gt; > > from an interactive shell: > > > > > > import pycountry > > > country = pycountry.countries.get(alpha2='DE') > > > currency = pycountry.currencies.get(numeric=country.numeric) > > > Traceback (most recent call last): > > > File