Re: [Tutor] creat a program that reads frequency of words in file

2015-06-02 Thread Alan Gauld
On 02/06/15 00:42, Alan Gauld wrote: forwordintext: ifwordnot inwords: words[word] =1 else: words[word] +=1 Look into the setdefault() method of dictionaries. It can replace the if/else above. On reflec

[Tutor] Fwd: Re: Parsing/Crawling test College Class Site.

2015-06-02 Thread Alan Gauld
Forwarding to list. Always use ReplyAll (or reply List if you have that option) to include the list. Forwarded Message Subject:Re: [Tutor] Parsing/Crawling test College Class Site. Date: Mon, 1 Jun 2015 20:42:48 -0400 From: bruce To: Alan Gauld Seriously

[Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Stephanie Quiles
Good evening, As you may have noticed i am really struggling with functions and dictionaries. I need to figure out why this program is allowing me to continue entering incorrect data instead of telling me my answer is incorrect. also at the end it’s not tallying the incorrect/correct responses

Re: [Tutor] creat a program that reads frequency of words in file

2015-06-02 Thread Stephanie Quiles
thanks on the help. I am now stuck on this program for quizzing on state capitals. Do you mind taking a look please? I can’t get it to tell me the answer is incorrect it just keeps asking me for capitals whether the answer is right or wrong. It also is not giving me correct counts for correct an

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Peter Otten
Stephanie Quiles wrote: > Good evening, > > As you may have noticed i am really struggling with functions and > dictionaries. I need to figure out why this program is allowing me to > continue entering incorrect data instead of telling me my answer is > incorrect. also at the end it’s not tallyin

Re: [Tutor] Trouble using bioread to convert files from .acq to .mat

2015-06-02 Thread Laura Creighton
In a message of Mon, 01 Jun 2015 15:50:26 -0400, Ila Kumar writes: >Hello, > >I am a new Python user attempting to use bioread ( >https://pypi.python.org/pypi/bioread/0.9.5) to convert files from >aqknowledge to matlab. I am using a 64-bit PC, and I have downloaded >Matlab, Python, numpy, scipy and

Re: [Tutor] creat a program that reads frequency of words in file

2015-06-02 Thread Alan Gauld
On 02/06/15 02:35, Stephanie Quiles wrote: import pickle You don;t need pickle def main(): right = 0 wrong = 0 capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', \ \ "Arizona": 'Phoenix', \ You don't need the \ Inside {} you can put newlines as much a

Re: [Tutor] Fwd: Re: Parsing/Crawling test College Class Site.

2015-06-02 Thread Alan Gauld
On 02/06/15 08:27, Alan Gauld wrote: The following is a sample of the test code, as well as the url/posts of the pages as produced by the Firefox/Firebug process. I'm not really answering your question but addressing some issues in your code... execfile('/apps/parseapp2/ascii_strip.py') exec

Re: [Tutor] unittest with random population data

2015-06-02 Thread Sydney Shall
On 02/06/2015 07:59, Steven D'Aprano wrote: Please keep your replies on the tutor list, so that others may offer advice, and learn from your questions. Thanks, Steve On Mon, Jun 01, 2015 at 06:03:08PM +0100, Sydney Shall wrote: On 31/05/2015 00:41, Steven D'Aprano wrote: On Sat, May 30, 2015

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Joel Goldstick
On Tue, Jun 2, 2015 at 3:43 AM, Peter Otten <__pete...@web.de> wrote: > Stephanie Quiles wrote: > >> Good evening, >> >> As you may have noticed i am really struggling with functions and >> dictionaries. I need to figure out why this program is allowing me to >> continue entering incorrect data ins

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread ZBUDNIEWEK . JAKUB
I'm a newbie, but was able to tune it to correctly reply to user inputs. 1. My question is can it be optimized in any way? 2. Why (on Windows) do I have to give inputs in quotes not to cause an error (for ll input the error is ' NameError: name 'll' is not defined')? def main(): right = 0

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Peter Otten
ZBUDNIEWEK. JAKUB wrote: > I'm a newbie, but was able to tune it to correctly reply to user inputs. > 2. Why (on Windows) do I have to give inputs in quotes not to cause an > error (for ll input the error is ' NameError: name 'll' is not defined')? If you are running the script under Python 2 yo

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Stephanie Quiles
Thank you all for your help! I have a text today but I am not confident with this. So basically, what I did wrong was the indentation? Thanks Stephanie Quiles Sent from my iPhone > On Jun 2, 2015, at 10:15 AM, Peter Otten <__pete...@web.de> wrote: > > ZBUDNIEWEK. JAKUB wrote: > >> I'm a new

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Alan Gauld
On 02/06/15 15:50, Stephanie Quiles wrote: > So basically, what I did wrong was the indentation? Yes. In Python indentation is all important. When you write a for (or while) loop Python executes all the indented code under the opening loop statement. When it sees an unindented statement it reads

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Alan Gauld
On 02/06/15 15:15, Peter Otten wrote: Not an optimization, but if the user enters neither Y nor N you might ask again instead of assuming Y. He does. He only breaks if the user enters N choice = input('Do you want to play again y/n: ') if choice.upper() == 'N':

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Alan Gauld
On 02/06/15 09:45, ZBUDNIEWEK.JAKUB wrote: I'm a newbie, but was able to tune it to correctly reply to user inputs. 1. My question is can it be optimized in any way? Code can nearly always be optimised. Whether it is worth doing so depends on the need to do so. In this case I douybt its worthwh

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Peter Otten
Alan Gauld wrote: > On 02/06/15 15:15, Peter Otten wrote: > >> Not an optimization, but if the user enters neither Y nor N you might ask >> again instead of assuming Y. > > He does. He only breaks if the user enters N > >>> choice = input('Do you want to play again y/n: ') >>>

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Stephanie Quiles
What is the +k+ called? How exactly does it work? I'm a big confused on that... Stephanie Quiles Sent from my iPhone > On Jun 2, 2015, at 12:17 PM, Peter Otten <__pete...@web.de> wrote: > > Alan Gauld wrote: > >>> On 02/06/15 15:15, Peter Otten wrote: >>> >>> Not an optimization, but if the

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Alan Gauld
On 02/06/15 17:17, Peter Otten wrote: choice = input('Do you want to play again y/n: ') if choice.upper() == 'N': print('end of game') break elif choice.upper() != 'Y': print("invalid choice") Y goes round again silently.

Re: [Tutor] creating a dictionary for capital quiz program

2015-06-02 Thread Alan Gauld
On 02/06/15 17:25, Stephanie Quiles wrote: What is the +k+ called? How exactly does it work? I'm a big confused on that... You seem to be replying to the wrong post. I assume you mean this one from Joel? - >> for k in capitals.keys(): >> state = input('Enter the

Re: [Tutor] unittest with random population data

2015-06-02 Thread Sydney Shall
On 31/05/2015 03:00, Cameron Simpson wrote: On 30May2015 12:16, Sydney Shall wrote: Following advice from you generous people, I have chosen a project >that interests me, to develop some knowledge of python. My projest is a simulation of a biological population. I have a base class and a simula