Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Dave Angel
On 01/-10/-28163 02:59 PM, tax botsis wrote: I have the following txt file that has 4 fields that are tab separated: the first is the id and the other three show the results per test. 152 TEST1 valid TEST3 good TEST2 bad 158 TEST2 bad TEST1 bad TEST4 valid . . . Based on the above txt I need to

[Tutor] Nodes and Queues?

2011-05-11 Thread Clara Mintz
Hi all I am sorry I am a beginner at python and I was reading my book and I came across the terms Nodes and Queue. I am sorry but I don't quite understand how they work. Is there anyone who could possibly explain them in simple terms? Thank you so much. Sincerely, Clara

[Tutor] Python program with multiple answers

2011-05-11 Thread Johnson Tran
Hi Guys, I've been working on a Python program where I create an 8 ball that will allow you to ask questions and will reply back with 20 possible answers. It will be continuous until the user says quit. My program works fine although I am trying to add something more to it, where when the user

Re: [Tutor] Nodes and Queues?

2011-05-11 Thread Patrick Sabin
A queue is a data structure, which keeps track of multiple objects. You can add data to a queue or you can remove it. When you remove an object from a queue you get the element which you have added first. Therefore, it is also called FIFO (First In First Out). A basic implementation could look

Re: [Tutor] Python program with multiple answers

2011-05-11 Thread Patrick Sabin
* Create a list. * Each time, the user gets an answer add it to the list * At the end of the program: sort the list and print each element of it - Patrick On 2011-05-11 12:49, Johnson Tran wrote: Hi Guys, I've been working on a Python program where I create an 8 ball that will allow you to

Re: [Tutor] Python program with multiple answers

2011-05-11 Thread Brett Ritter
On Wed, May 11, 2011 at 6:49 AM, Johnson Tran wrote: > I've been working on a Python program where I create an 8 ball that will > allow you to ask questions and will reply back with 20 possible answers. ... > if anyone could point me in the right direction it'd be really helpful Answer cloudy, t

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Walter Prins
On 11 May 2011 03:57, tax botsis wrote: > I tried to work that out with xlwt but couldn't. Actually, I started > working on the following script but I couldn't even split the line for > further processing: > > OK, I've thrown together a quick sample demonstrating all the concepts you need (obviou

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread tee chwee liong
hi all, thanks for this sharing. when i copy and run this code, i got this error: Traceback (most recent call last): File "C:/Python25/myscript/excel/sampleexcel.py", line 1, in import csv File "C:/Python25/myscript/excel\csv.py", line 3, in w=csv.writer(open('output.csv','w'))

[Tutor] 3 Level Snake Game Made using Pygame API

2011-05-11 Thread ANKUR AGGARWAL
Hey Few weeks back I made out the basic of the snake game and released it on the Web under the file name "hungry.py". Now I Upgraded It Into a 3 Level Game. I test it on windows too and its working completely fine over there too. Download the "Game.Zip" file to play all the three levels and "hungry

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Walter Prins
On 11 May 2011 14:34, tee chwee liong wrote: > hi all, > > thanks for this sharing. when i copy and run this code, i got this error: > > Traceback (most recent call last): > File "C:/Python25/myscript/excel/sampleexcel.py", line 1, in > import csv > File "C:/Python25/myscript/excel\csv.

Re: [Tutor] Python program with multiple answers

2011-05-11 Thread Johnson Tran
Thanks for all the replies. But, sorry I am getting a little confused. I have never created a list before and am not really sure where to start. If I put a "answer_list=[]" before the while True: line...is this correct? Or to go by Brett's method, how would I go about saving the questions and a

Re: [Tutor] Python program with multiple answers

2011-05-11 Thread taserian
In addition to the wise counsel you've already received, I noticed that your randint goes from 0 to 10, but you have 20 possible outcomes in dice(). If I'm counting correctly, it should be roll=random.randint(0, 19). Tony R. On Wed, May 11, 2011 at 6:49 AM, Johnson Tran wrote: > Hi Guys, > > I'

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread James Reynolds
Slow day at work, so I tried something a little different mostly as a learning exercise for myself, let me know what you all think. I thought it would be useful to have a writer that scales and that organizes the data. For example, you might have 20 tests one day, and 5 the next. I broke up the d

Re: [Tutor] Python program with multiple answers

2011-05-11 Thread bodsda
Hi, I would suggest appending the dice[roll] to a new list just after the print statement, then in the quit block order the list and then loop over it and print each entry. Hope this helps, Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Johnson Tran Sender: t

Re: [Tutor] Python program with multiple answers

2011-05-11 Thread Alan Gauld
"Johnson Tran" wrote import random dice = ... while True: ... elif choice == "quit": True = 0 raw_input() Do not do this! True is supposed to be a fixed, constant boolean value. In fact in Python v3 you will get an error if you try it. Instead use break to exit from the loop.

[Tutor] Python Hard_way 40

2011-05-11 Thread Robert .
Hi all, My first post ever! :) I'm following the guide "Learn Python the Hard Way" and have reached a point where I am struggling to understand the code and unfortunately the authors guide hasn't cleared it up for me. (excercise 40 for reference) The main confusion is coming from* 'cities['_find'

Re: [Tutor] Python program with multiple answers

2011-05-11 Thread Alan Gauld
"Johnson Tran" wrote If I put a "answer_list=[]" before the while True: line...is this correct? Yes that creates an empty list. only trying to make a list of the answers, I probably do not need to save the questions ? Correct, but import random answer_list=[] while True:

Re: [Tutor] Nodes and Queues?

2011-05-11 Thread Alan Gauld
"Clara Mintz" wrote I am sorry I am a beginner at python and I was reading my book and I came across the terms Nodes and Queue. I am sorry but I don't quite understand how they work. Its a bit of Comp Science terminology. A Queue is a particular type of data structure somewhat like a Pytho

Re: [Tutor] Python program with multiple answers

2011-05-11 Thread Prasad, Ramit
I think it should be: import random dice = ("Without a doubt", "It is certain", "It is decidedly so","Yes", "For Sure", "No", "Dont count on it", "Try asking again","Reply hazy, try again", "Confucious says 'No'", "Better not tell you now","Cannot predict now","Concentrate and ask again","My re

Re: [Tutor] Python Hard_way 40

2011-05-11 Thread bob gailer
On 5/11/2011 11:24 AM, Robert . wrote: Hi all, My first post ever! :) I'm following the guide "Learn Python the Hard Way" and have reached a point where I am struggling to understand the code and unfortunately the authors guide hasn't cleared it up for me. (excercise 40 for reference) The m

Re: [Tutor] Python Hard_way 40

2011-05-11 Thread Andre Engels
On Wed, May 11, 2011 at 5:24 PM, Robert . wrote: > Hi all, > > My first post ever! :) > I'm following the guide "Learn Python the Hard Way" and have reached a point > where I am struggling to understand the code and unfortunately the authors > guide hasn't cleared it up for me. (excercise 40 for r

Re: [Tutor] Python Hard_way 40

2011-05-11 Thread Prasad, Ramit
>>This stores a reference to the function. The following line is the call to >>the function. Just to expand. In Python, you can pass functions like you would anything else. So, the first line before stores the function reference find_city inside the dictionary cities with the key '_find'. It t

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread James Reynolds
your "\" is a "/" when writing out a string, such as 'C:\test.xls', the "/" is an escape in python. So you have two choices, You can either write out path = 'C:\\test.xls', which will be 'C:\test.xls' or you can write out path = r'C:\test.xls' the "r" bit tells python that the following is a regul

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Joel Goldstick
On Wed, May 11, 2011 at 1:26 PM, James Reynolds wrote: > your "\" is a "/" > > when writing out a string, such as 'C:\test.xls', the "/" is an escape in > python. So you have two choices, You can either write out path > = 'C:\\test.xls', which will be 'C:\test.xls' or you can write out path = > r

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Prasad, Ramit
>your "\" is a "/" >when writing out a string, such as 'C:\test.xls', the "/" is an escape in >python. So you have two choices, You can either write out path = 'C:\\test.xls', which will be 'C:\test.xls' or you can write out path = r'C:\test.xls' the "r" bit tells python that the following is a

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread James Reynolds
Yes, thank you. Actually, I never knew that about the windows separators, since I've just always used the '\' out of habit. On Wed, May 11, 2011 at 2:39 PM, Prasad, Ramit wrote: > > > >your "\" is a "/" > > > > >when writing out a string, such as 'C:\test.xls', the "/" is an escape in > python

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Steve Willoughby
On 11-May-11 12:14, James Reynolds wrote: Actually, I never knew that about the windows separators, since I've just always used the '\' out of habit. If you want your code to run everywhere, you should use the functions in os.path to manipulate and build paths. Otherwise, using \ all the tim

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread davidheiserca
I'm not contradicting anyone, just relating my experience. I have a large suite of Python programs that run routinely on both Windows and Linux systems. Some of the programs build large directory tree structures. I cast all directory delimiters to the forward slash "/". No problems. -

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Prasad, Ramit
>Core windows commands don't generally accept it, including native >Windows applications (although sometimes they're lenient in what they >accept). It'll work for command-line Python script usage because it's >*python* that allows them, not *windows*. They work in *Windows* command prompt nati

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Steve Willoughby
On 11-May-11 15:54, Prasad, Ramit wrote: Core windows commands don't generally accept it, including native Windows applications (although sometimes they're lenient in what they accept). It'll work for command-line Python script usage because it's *python* that allows them, not *windows*. They

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread tee chwee liong
excellent it works. tq Date: Wed, 11 May 2011 14:58:39 +0100 Subject: Re: [Tutor] create an xls file using data from a txt file From: wpr...@gmail.com To: tc...@hotmail.com CC: taxbot...@gmail.com; tutor@python.org On 11 May 2011 14:34, tee chwee liong wrote: hi all, thanks for this