Re: [Tutor] Optimisation of prime number program (cont. from finding prime numbers)

2007-09-26 Thread Kalle Svensson
Hi! Just a followup on this: On 9/21/07, Kalle Svensson <[EMAIL PROTECTED]> wrote: > Hi! > > On 9/21/07, Boykie Mackay <[EMAIL PROTECTED]> wrote: > > Ok,I have learnt how to generate prime numbers and how to 'split' > > input.The above was to help me solve the second 'SPOJ' > > challenge,PRIME1.T

Re: [Tutor] New to Python and Linux

2007-09-26 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Well, chmod 0700 is usually not want you want: a) 0700 gives only read/write/execute rights to the user. Technically for historical reason permissions can be written as an octal number, with the first digit being optional, encoding stuff like setuid/s

Re: [Tutor] home_finance.py

2007-09-26 Thread Eric Walker
I think you need to check to see if the remaining amount is less than the payment amount. Eric... Christopher Spears <[EMAIL PROTECTED]> wrote: I'm working on a problem in Chapter 5 of Core Python Programming(2nd Edition). I am supposed to write a script that take an opening balance and a mont

[Tutor] copy files + directory tree via ftp

2007-09-26 Thread Nelson Kusuma
Hello I have a problem when copy files and directory tree in ftp, scripts in here only copy one file: from ftplib import FTP rootList = [] session = FTP() session.connect('workstation', port=21) session.login(user='saiki', passwd='saiki') session.retrlines('LIST', rootList.append) f=open('D:/PARAM

Re: [Tutor] Optimisation of prime number program (cont. from finding prime numbers)

2007-09-26 Thread Kent Johnson
Kalle Svensson wrote: > After quite a bit of experimentation, I finally managed to write a > program that was accepted by the judge system. It's a C++ > implementation of the deterministic Miller-Rabin algorithm. My Python > implementation of the same algorithm is still too slow, though. Has > anyo

Re: [Tutor] copy files + directory tree via ftp

2007-09-26 Thread Kent Johnson
Nelson Kusuma wrote: > Hello > > I have a problem when copy files and directory tree in > ftp, scripts in here only copy one file: To transfer an entire directory with ftplib you will have to read the local directory with os.listdir() and loop to send the files. There are a few higher-level mod

Re: [Tutor] home_finance.py

2007-09-26 Thread Ricardo Aráoz
Eric Walker wrote: > I think you need to check to see if the remaining amount is less than > the payment amount. > > Eric... Or just subtract the minimum between the remaining amount and the payment amount. See below > > */Christopher Spears <[EMAIL PROTECTED]>/* wrote: > > I'm working on

Re: [Tutor] python problem

2007-09-26 Thread bhaaluu
Greetings Chris, On 9/25/07, Chris <[EMAIL PROTECTED]> wrote: > > Ok as I see it, it's should go like this: > > Print 'Think of a number between 1 and 100, and let me guess it' > > Type1 = input ('Type 1 if I am high') > Type2 = input ('Type 2 if I am low') > Type3 = input ('Type 3 if I am dead

Re: [Tutor] python problem

2007-09-26 Thread Kent Johnson
Chris wrote: > Ok as I see it, it's should go like this: > > Print 'Think of a number between 1 and 100, and let me guess it' > > Type1 = input ('Type 1 if I am high') > Type2 = input ('Type 2 if I am low') > Type3 = input ('Type 3 if I am dead on') This will ask for three different inputs whi

Re: [Tutor] New to Python and Linux

2007-09-26 Thread bhaaluu
Greetings, I don't know how to do ms-windows, but I use GNU/Linux on a daily basis. There is a nice IDE (Integrated Development Environment) for Python called IDLE. It is available for ms-windows, GNU/Linux, and maybe another OS as well. There is information about IDLE at Python.Org. I'd suggest

[Tutor] indexing question

2007-09-26 Thread Emad Nawfal
Hi Tutors, Is there a way to get the index of every occurence of a certain element in a list. listname.index(element) gives me the index of the first occurence. For example: >>> t = 'we are we are we we we'.split() >>> t ['we', 'are', 'we', 'are', 'we', 'we', 'we'] >>> for word in t: if word =='

Re: [Tutor] indexing question

2007-09-26 Thread Kent Johnson
Emad Nawfal wrote: > Hi Tutors, > Is there a way to get the index of every occurence of a certain element > in a list. listname.index(element) gives me the index of the first > occurence. For example: > > >>> t = 'we are we are we we we'.split() > Now I want the index of each 'we' in t. I want

[Tutor] Re: New to Python and Linux

2007-09-26 Thread 林培恒
Hi Armand, I suggest you learn Linux command line first. It is the basic skill in Linux world, like double-click in Windows. If you know how to run a program in Windows with double-click, you will understand how to run most program in Windows. If you know how to run a program with comman

[Tutor] Re: New to Python and Linux

2007-09-26 Thread 林培恒
Hi Armand, I suggest you learn Linux command line first. It is the basic skill in Linux world, like double-click in Windows. If you know how to run a program in Windows with double-click, you will understand how to run most program in Windows. If you know how to run a program with comman

[Tutor] Python for animation

2007-09-26 Thread Babajide, Owojaiye
Hi all, I'm looking for a tutorial PDF file of Python that is dedicated to animation and special effects,can ahyone help?If you can please forward to the following address: [EMAIL PROTECTED] [EMAIL PROTECTED] THANKS This

[Tutor] questions about tuples

2007-09-26 Thread Fangwen Lu
Dear all- I want to do some loops. Each loop will generate a tuple. Eventually I want to put tuples together in a higher level of tuple. Do you know how to do this? Say a=(1,2,3), b=(4,3,2),c=(9,5,6). I want to get a tuple as ((1,2,3), (4,3,2),(9,5,6)). If there are just 2 tuples, I can write x

[Tutor] print array

2007-09-26 Thread Fangwen Lu
Dear all- Let a=(3,4,7), b=[3,4,7]. If I type print '%d + %d = %d' %(a) I get 3 + 4 = 7 But if I type print '%d + %d = %d' %(b), I get errors. If there is a way for doing this kind of type dirrectly from array. Thank you! Fangwen ___ Tutor maillist

[Tutor] how to convert array into tuple

2007-09-26 Thread Fangwen Lu
Dear all- If I have an array array([1, 2, 3, 4, 5, 6]), and I want to get ((1,2),(3,4),(5,6)). What should I do? Thank you! Fangwen ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] questions about tuples

2007-09-26 Thread Ricardo Aráoz
Fangwen Lu wrote: > Dear all- > > I want to do some loops. Each loop will generate a tuple. Eventually I > want to put tuples together in a higher level of tuple. Do you know how > to do this? > > Say a=(1,2,3), b=(4,3,2),c=(9,5,6). I want to get a tuple as ((1,2,3), > (4,3,2),(9,5,6)). > > I

Re: [Tutor] print array

2007-09-26 Thread Eric Brunson
Fangwen Lu wrote: > Dear all- > > Let a=(3,4,7), b=[3,4,7]. > If I type > print '%d + %d = %d' %(a) > I get > 3 + 4 = 7 > > But if I type print '%d + %d = %d' %(b), I get errors. > > If there is a way for doing this kind of type dirrectly from array. No, but it's trivial to convert an array

Re: [Tutor] questions about tuples

2007-09-26 Thread Eric Brunson
Fangwen Lu wrote: > Dear all- > > I want to do some loops. Each loop will generate a tuple. Eventually I > want to put tuples together in a higher level of tuple. Do you know > how to do this? > > Say a=(1,2,3), b=(4,3,2),c=(9,5,6). I want to get a tuple as ((1,2,3), > (4,3,2),(9,5,6)). >

Re: [Tutor] how to convert array into tuple

2007-09-26 Thread Ricardo Aráoz
Fangwen Lu wrote: > Dear all- > > If I have an array array([1, 2, 3, 4, 5, 6]), and I want to get > ((1,2),(3,4),(5,6)). What should I do? > tuple([j for (i,j) in enumerate(zip(x, x[1:])) if i % 2 == 0]) ___ Tutor maillist - Tutor@python.org http:

Re: [Tutor] print array

2007-09-26 Thread Ricardo Aráoz
Fangwen Lu wrote: > Dear all- > > Let a=(3,4,7), b=[3,4,7]. > If I type > print '%d + %d = %d' %(a) > I get > 3 + 4 = 7 > > But if I type print '%d + %d = %d' %(b), I get errors. > > If there is a way for doing this kind of type dirrectly from array. > print '%d + %d = %d' % tuple(b)

Re: [Tutor] how to convert array into tuple

2007-09-26 Thread Eric Brunson
Fangwen Lu wrote: > Dear all- > > If I have an array array([1, 2, 3, 4, 5, 6]), and I want to get > ((1,2),(3,4),(5,6)). What should I do? First, you read some documentation and tutorials on the language, then you iterate over the list and build tuples out of the elements. > > Thank you! >

Re: [Tutor] python problem

2007-09-26 Thread Chris
Here some more work: guess = 0 Print ‘Pick a number between 0 and 100’ While guess != : print ‘My first guess is ‘, guess print ‘Is my guess correct?’ if guess = = type3 print ‘I got it!’ if guess > ___: pick l

[Tutor] Where can I find simple python scripts to edit and play around?

2007-09-26 Thread Ulrich Holtzhausen
Well I guess the subject/topic here describes it all. I am looking for a nice collection of SIMPLE python scripts, IE: How to manipulate files, text, how to create a bot, how to work with socks...making a server/client, converting decimal to binary etc. etc. etc. Example scripts since I am havi

Re: [Tutor] Where can I find simple python scripts to edit and play around?

2007-09-26 Thread bhaaluu
http://examples.oreilly.com/python3/ http://aspn.activestate.com/ASPN/Cookbook/Python/ http://examples.oreilly.com/twistedadn/ http://www.vex.net/parnassus/ I guess you could start with those and see what you can find? -- b h a a l u u at g m a i l dot c o m http://www.geocities.com/ek.bhaaluu/in

Re: [Tutor] Where can I find simple python scripts to edit and play around?

2007-09-26 Thread Andrew Nelsen
On 9/26/07, Ulrich Holtzhausen <[EMAIL PROTECTED]> wrote: > > Well I guess the subject/topic here describes it all. I am looking for a > nice collection of SIMPLE python scripts, IE: How to manipulate files, > text, how to create a bot, how to work with socks...making a > server/client, converting

Re: [Tutor] Where can I find simple python scripts to edit and play around?

2007-09-26 Thread Kent Johnson
Ulrich Holtzhausen wrote: > Well I guess the subject/topic here describes it all. I am looking for a > nice collection of SIMPLE python scripts, http://aspn.activestate.com/ASPN/Cookbook/Python as well as the printed version already referenced. http://diveintopython.org/ has fairly long examples

[Tutor] do i have to import modules at the start of a file?

2007-09-26 Thread shawn bright
lo there all, i have a gui program that imports a few modules that i don't need if i am using the program remotely. The program has an admin interface and thread interface, only the admin interface is needed when i am using the program from a remote computer. all of my modules are imported at the

Re: [Tutor] do i have to import modules at the start of a file?

2007-09-26 Thread Kent Johnson
shawn bright wrote: > lo there all, > > i have a gui program that imports a few modules that i don't need if i > am using the program remotely. > The program has an admin interface and thread interface, only the admin > interface is needed when > i am using the program from a remote computer. >

[Tutor] still need help..

2007-09-26 Thread Chris
Here some more work: guess = 0 Print ?Pick a number between 0 and 100? While guess != : print ?My first guess is ?, guess print ?Is my guess correct?? if guess = = type3 print ?I got it!? if guess > ___: pick

Re: [Tutor] still need help..

2007-09-26 Thread Kent Johnson
Chris wrote: > > Here some more work: > > > guess = 0 > > Print ?Pick a number between 0 and 100? > > > While guess != : > print ?My first guess is ?, guess > print ?Is my guess correct?? > if guess = = type3 > print ?I got it!? > if guess

[Tutor] i am stuck...

2007-09-26 Thread Chris
I don't know what to do at this point. I do not have the book, but will get it just to have... Can anyone help me? > Here some more work: > > > guess = 0 > > Print ?Pick a number between 0 and 100? > > > While guess != : > print ?My first guess is ?, guess > print ?Is m

Re: [Tutor] i am stuck...

2007-09-26 Thread Ian Witham
On 9/27/07, Chris <[EMAIL PROTECTED]> wrote: > > I don't know what to do at this point. I do not have the book, but will > get > it just to have... > > Can anyone help me? > > > Here some more work: > > > > > > guess = 0 > > > > Print ?Pick a number between 0 and 100? > > > > > > While guess != __

Re: [Tutor] i am stuck...

2007-09-26 Thread Ian Witham
On 9/27/07, Ian Witham <[EMAIL PROTECTED]> wrote: > > On 9/27/07, Chris <[EMAIL PROTECTED]> wrote: > > > > I don't know what to do at this point. I do not have the book, but will > > get > > it just to have... > > > > Can anyone help me? > > > > > Here some more work: > > > > > > > > > guess = 0 >