Re: [Tutor] New to Python and Linux

2007-09-25 Thread Jason M Barnes
Hi, Another way to execute your program is to open up your file with gedit, and on the very first line type (sans quotes) "#!/usr/bin/env python" by itself and save it. Then, go to the terminal like Michael said, and cd into the directory with your file. Type "chmod 0700 your-program.py" at the

Re: [Tutor] New to Python and Linux

2007-09-25 Thread Michael Langford
Somewhere in the start menu, you'll be able to open a terminal. It might be called GTerm, Gnome Term, xterm, or any number of things with "term" in the name. Once you've done that, you need to see if python is in your path. Do that by typing python in the terminal. If you enter the python shell, y

[Tutor] New to Python and Linux

2007-09-25 Thread Armand Nell
Hi I am new to python programming and also the linux enviroment most of my skills are windows based and programming skills is visual basics. I decided that it would be a great start and new direction for me to learn python and at the same time linux. However I have already run into a wall, and any

Re: [Tutor] home_finance.py

2007-09-25 Thread Ian Witham
On 9/26/07, 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 monthly > payment from the user. The script then displays the > balance and payments

Re: [Tutor] python problem

2007-09-25 Thread Chris
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') I can't seem to get the guts of it. I assume that there are 3 if stat

Re: [Tutor] python problem

2007-09-25 Thread Kent Johnson
Chris wrote: > Guess the number from the user using 1,2,3 keys > Ask the user if # is high, low, or dead on. > Print 'you got it' when Python gets it. > > As you can see I need help. I've given you the pseudo code. OK, how about some real code? If we write the program for you

Re: [Tutor] pickle question

2007-09-25 Thread Kent Johnson
Jeff Peery wrote: > hello, > > I have a question about the pickler. I'm using it to save objects in a > program of mine that I can later reload to use. I was wondering how the > pickle works and how it references the class module when I unpickle the > pickled objects. for example I save some o

Re: [Tutor] python problem

2007-09-25 Thread Chris
Ok, in this case the guessing game is design to guess the number (0-100) that the user holds in his head. I assume that Python off the bat Python gives a first guess. Example: I guess 50 #(using the split range) Depending on the user # Python asks: Press 1 if I am high. Press 2 if I am low. Pr

[Tutor] home_finance.py

2007-09-25 Thread Christopher Spears
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 monthly payment from the user. The script then displays the balance and payments like so: Enter opening balance: 100 Enter monthly payment: 16.13

Re: [Tutor] Take if offline

2007-09-25 Thread Hansen, Mike
h!!! You posted in HTML and top posted! OH NO! I top-posted too! """ runs away screaming and bouncing off the walls like Daffy Duck """ _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fiyawerx Sent: Tuesday, September 25, 2007 6:45 PM To: Darren Williams Cc

Re: [Tutor] Take if offline

2007-09-25 Thread Fiyawerx
It also seems, for people like me, I've learned a lot of 'what not to do' by seeing peoples replies to others posts telling them.. well, what not to do. If all these were taken 'off list' you'd have a whole lot more people doing bad things because they wouldn't have seen yet not to do it, not to me

Re: [Tutor] data type conversion for print statement

2007-09-25 Thread O.R.Senthil Kumaran
> > The 'print' statement is hardcoded to add a space between elements. > print is meant to make output easy, at the cost of control. Well, that was a good example. I had prepared Notes for myself also along the same lines. print and softspace in python In python, whenever you use >>>print sta

[Tutor] pickle question

2007-09-25 Thread Jeff Peery
hello, I have a question about the pickler. I'm using it to save objects in a program of mine that I can later reload to use. I was wondering how the pickle works and how it references the class module when I unpickle the pickled objects. for example I save some objects using the pickler,

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
On 9/26/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Tue, 25 Sep 2007, Ian Witham wrote: > > def numfaczeroes(n): > """ > return the count of trailing zeroes from n! > e.g., 10! = 3628800; count of trailing zeros = 2 > """ > exponent = 1 > fivecount = 0 > while (n

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
On 9/26/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Wed, 26 Sep 2007, Ian Witham wrote: > > > My solution still took over 5 seconds on the Sphere Judge machine. > > How much data are they throwing at you? For the sample data they provide > on the website, your first "slow" solution finishe

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Terry Carroll
On Wed, 26 Sep 2007, Ian Witham wrote: > My solution still took over 5 seconds on the Sphere Judge machine. How much data are they throwing at you? For the sample data they provide on the website, your first "slow" solution finished on my machine almost instantaneously. _

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
> > > from itertools import count, takewhile > > def numfaczeroes2(n): > def while_(e): > return n//(5**e) > 0 > return sum(n//(5**exponent) for exponent in takewhile(while_, > count(1))) > > > It is quite a bit slower, though; probably because of the extra function > call introd

Re: [Tutor] Take if offline

2007-09-25 Thread Darren Williams
All jokes aside now (glad you took it that way Mike). Maybe I havn't gave the tutor enough attention, but I have never witnessed someone jump down anothers throat because they posted in all caps, didn't enter a subject etc... etc... The one time I have seen an argument (well heated debate) was

Re: [Tutor] data type conversion for print statement

2007-09-25 Thread Kent Johnson
Noufal Ibrahim wrote: > I suppose you could also do but it's a little less readable > print "%sand this %sneeds to check %s"%tuple([str(x) for x in > (val1,val2,val3)]) The %s formatter takes care of the string conversion, the list comprehension is not needed. Just use print "%sand this %sneed

Re: [Tutor] Take if offline

2007-09-25 Thread Michael Langford
I agree with Kent... -- Michael Langford Phone: 404-386-0495 Consulting: http://www.TierOneDesign.com/ Entertaining: http://www.ThisIsYourCruiseDirectorSpeaking.com On 9/25/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > Hansen, Mike wrote: > > Anytime someone posts in HTML, or posts without a s

Re: [Tutor] data type conversion for print statement

2007-09-25 Thread Noufal Ibrahim
Tim wrote: > Hello, > I have a print statement where I use concatenation of variables with "+" to > avoid extra whitespaces. The variables are mixed (float/int). > > How can I convert them all to strings to have a clean print statement? > > example > print str(var1)+"and this "+str(var2)+"needs t

Re: [Tutor] Take if offline

2007-09-25 Thread Kent Johnson
Hansen, Mike wrote: > Anytime someone posts in HTML, or posts without a subject, or > accidentally > hijacks a thread, or top-posts, or writes in caps, a couple of posters > pop up > and complain. Rather than posting to the entire list, I think it'd be > best if > you send your complaint directly t

Re: [Tutor] largest and smallest numbers (Linpeiheng)

2007-09-25 Thread Noufal Ibrahim
林培恒 wrote: > On Mon, 24 Sep 2007, Terry Carroll write: > >> My math is rusty. Is there a concept of "greater than" >> or "largest" in complex numbers on different axis? Which >> is larger, 4+2i or 2+4i? > > In fact, complex numbers can not compare directly. People always compare > complex numbe

Re: [Tutor] Take if offline

2007-09-25 Thread Darren Williams
So by your own rules, you should have sent that to the offending user(s). - Original Message - From: "Hansen, Mike" <[EMAIL PROTECTED]> To: "python tutor" Sent: Tuesday, September 25, 2007 2:27 PM Subject: [Tutor] Take if offline > Anytime someone posts in HTML, or posts without a subj

[Tutor] Take if offline

2007-09-25 Thread Hansen, Mike
Anytime someone posts in HTML, or posts without a subject, or accidentally hijacks a thread, or top-posts, or writes in caps, a couple of posters pop up and complain. Rather than posting to the entire list, I think it'd be best if you send your complaint directly to the "offending" user. I'd prefer

Re: [Tutor] data type conversion for print statement

2007-09-25 Thread Kent Johnson
Tim wrote: > Hello, > I have a print statement where I use concatenation of variables with "+" to > avoid extra whitespaces. The variables are mixed (float/int). > > How can I convert them all to strings to have a clean print statement? > > example > print str(var1)+"and this "+str(var2)+"needs t

Re: [Tutor] data type conversion for print statement

2007-09-25 Thread Tom Tucker
Excerpt from an email Danny Yoo sent to me and the list in 2005. I had the same question. ;-) Hi Tom, The 'print' statement is hardcoded to add a space between elements. print is meant to make output easy, at the cost of control. If we need more fine-grained control over output, we may want t

[Tutor] data type conversion for print statement

2007-09-25 Thread Tim
Hello, I have a print statement where I use concatenation of variables with "+" to avoid extra whitespaces. The variables are mixed (float/int). How can I convert them all to strings to have a clean print statement? example print str(var1)+"and this "+str(var2)+"needs to check "+str(var3) how ca

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Kent Johnson
Terry Carroll wrote: > On Tue, 25 Sep 2007, Ian Witham wrote: > >> As I was using a list comprehension I wasn't sure how to make the >> calculations stop when the result of integer division == 0. > > I don't see how to do that, either. Someone on this list (sorry, I forget > who) once suggested

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Terry Carroll
On Tue, 25 Sep 2007, Ian Witham wrote: > As I was using a list comprehension I wasn't sure how to make the > calculations stop when the result of integer division == 0. I don't see how to do that, either. Someone on this list (sorry, I forget who) once suggested that the list comprehension shou

Re: [Tutor] largest and smallest numbers

2007-09-25 Thread Terry Carroll
On Tue, 25 Sep 2007, John Fouhy wrote: > You've got upper and lower bounds - maybe you could do a binary search > to find the max exactly? It should only take the same number of steps > again... I thought of that; and then I thought I'd rather go home and have dinner. ___

Re: [Tutor] largest and smallest numbers (Linpeiheng)

2007-09-25 Thread 林培恒
On Mon, 24 Sep 2007, Terry Carroll write: >My math is rusty. Is there a concept of "greater than" >or "largest" in complex numbers on different axis? Which >is larger, 4+2i or 2+4i? In fact, complex numbers can not compare directly. People always compare complex numbers with their 'model'. For

Re: [Tutor] Need help speeding up algorithm. (Terry Carroll)

2007-09-25 Thread Carnell, James E
Terry, I liked your answer! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] python problem

2007-09-25 Thread bhaaluu
On 9/25/07, Chris <[EMAIL PROTECTED]> wrote: > I have this GUESSING GAME code found below: > - > import random > number = random.randint(1, 101) > print "I've thought of a number between 1 and 100." > print "Try and guess it!" > print > guess = input( "What's your guess? ") > wh

Re: [Tutor] largest and smallest numbers

2007-09-25 Thread John Fouhy
You've got upper and lower bounds - maybe you could do a binary search to find the max exactly? It should only take the same number of steps again... On 9/25/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > On Mon, 24 Sep 2007, Christopher Spears wrote: > > > How can I find the largest float and com