[Tutor] Windows Power Shell

2010-08-21 Thread Alan Gauld
A recent windows update delivered the Windows Power Shell to my desktop. I'd heard of this but never used it till now. I've only started playing with it but it is essentially DOS on steroids. It brings Windows users a shell that seems to be very close to Unix shells like Bash in power and flex

Re: [Tutor] flow problem with a exercise

2010-08-21 Thread Roelof Wobben
From: waynejwer...@gmail.com Date: Fri, 20 Aug 2010 15:07:56 -0500 Subject: Re: [Tutor] flow problem with a exercise To: rwob...@hotmail.com CC: tutor@python.org On Fri, Aug 20, 2010 at 2:48 PM, Roelof Wobben wrote: Oke, I don''t understand it complety. return not arg%2 Why use n

Re: [Tutor] flow problem with a exercise

2010-08-21 Thread Evert Rol
> In [39]: t = 3 > > In [40]: round((t-32)/1.8) > Out[40]: -16.0 > > In [41]: t = 3.0 > > In [42]: round((t-32)/1.8) > Out[42]: -16.0 > > Works fine for me. > > Correct, > But I see one wierd thing. > > round ((42-32)/1.8) gives a output -16.0 but (42-32)/1.8) gives also -16.0 > I was expe

Re: [Tutor] flow problem with a exercise

2010-08-21 Thread Dave Angel
You need to figure out how to get your email program to do quoting. As it stands, there's no good way to tell what part of the following message was from you, and what part was from wayne, or maybe others. Probably all you need to do is to do a reply-all to the message, and it'll mark the ex

Re: [Tutor] flow problem with a exercise

2010-08-21 Thread Roelof Wobben
> Subject: Re: [Tutor] flow problem with a exercise > From: evert@gmail.com > Date: Sat, 21 Aug 2010 12:39:05 +0200 > CC: tutor@python.org > To: rwob...@hotmail.com > > > In [39]: t = 3 > > > > In [40]: round((t-32)/1.8) > > Out[40]: -16.0 > > > > In [41]: t = 3.0 > > > > In [42]: roun

[Tutor] check the terminal keyword

2010-08-21 Thread ANKUR AGGARWAL
i m making a app in which i launch application using os.system("input from user"). I want to check whether the input entered by the user matches with the exact keyword in terminal or not. like i want to launch vlc so user should provide me input as " vlc" in order to launch the app just like he did

[Tutor] prime test problem

2010-08-21 Thread Roelof Wobben
Hello, I have to make a programm which can test if a number is a prime. I know a prime is a number which can only be diveded by 1 and itself. One way is was thinking about is to make a loop which try if % has output 0. But that don't work. Can someone give me a hint what's the best

Re: [Tutor] prime test problem

2010-08-21 Thread Nitin Das
For this problem u will get lots of solutions on the net. e.g wilson's theorem , sieve of eranthoses etc. --nitin On Sat, Aug 21, 2010 at 7:05 PM, Roelof Wobben wrote: > Hello, > > I have to make a programm which can test if a number is a prime. > I know a prime is a number which can only be d

Re: [Tutor] prime test problem

2010-08-21 Thread Robert Berman
Googling 'computing prime numbers' produced about 64,100,000 results . That should certainly get you started. Robert From: tutor-bounces+bermanrl=cfl.rr@python.org [mailto:tutor-bounces+bermanrl=cfl.rr@python.org] On Behalf Of Roelof Wobben Sent: Saturday, August 21, 2010 9:36 AM To

Re: [Tutor] check the terminal keyword

2010-08-21 Thread Nitin Das
You can use raw_input like for e.g. u_input = raw_input("user_command") n then u can check u_input against anything. if doesn't matches then u can throw an error. I hope it shall help you. --nitin On Sat, Aug 21, 2010 at 6:37 PM, ANKUR AGGARWAL wrote: > i m making a app in which i launch applic

Re: [Tutor] check the terminal keyword

2010-08-21 Thread Evert Rol
> i m making a app in which i launch application using os.system("input from > user"). I want to check whether the input entered by the user matches with > the exact keyword in terminal or not. > like i want to launch vlc so user should provide me input as " vlc" in order > to launch the app jus

Re: [Tutor] prime test problem

2010-08-21 Thread Roelof Wobben
Hello, I know. I have read them all I believe but I can't see how I can convert the algebra to a working programm. Roelof Date: Sat, 21 Aug 2010 19:15:03 +0530 Subject: Re: [Tutor] prime test problem From: nitin@gmail.com To: rwob...@hotmail.com CC: tutor@python.org For this proble

Re: [Tutor] prime test problem

2010-08-21 Thread Roelof Wobben
Hello, I forget to mention that I try to follow this book : Think like a computer scientist and I'm now working on chapter 4. Roelof From: rwob...@hotmail.com To: tutor@python.org Date: Sat, 21 Aug 2010 14:41:03 + Subject: Re: [Tutor] prime test problem Hello, I know. I h

Re: [Tutor] prime test problem

2010-08-21 Thread Evert Rol
> Hello, > > I know. > I have read them all I believe but I can't see how I can convert the algebra > to a working programm. And if you just search Google for "Python prime number algorithm"? Perhaps it's cheating, so you'll have to try and fully understand the code first before you run it (

Re: [Tutor] prime test problem

2010-08-21 Thread Steven D'Aprano
On Sun, 22 Aug 2010 12:41:03 am Roelof Wobben wrote: > Hello, > > I know. > I have read them all I believe You've read all 64 million pages that Google finds? Wow, you must be a fast reader! Well done! > but I can't see how I can convert the > algebra to a working programm. Have you *tried*?

Re: [Tutor] prime test problem

2010-08-21 Thread Roelof Wobben
Hello, I tried it with this simple programm def is_prime(n): x=2 while x <= int(n**0.5)+1: if n % x == 0: return False x=x+1; return True x=is_prime(7) if x==True: print 7, "is een prime getal" else : print

Re: [Tutor] Windows Power Shell

2010-08-21 Thread Bill Allen
Alan, I have used WPS 1.0 for some time at work to script software installs, etc. It is very powerful and gives full .NET visibility to "DOS" level scripts. In fact, it is a plausible replacement for VB for most administrative scripting work in the Windows environment. Some good resources: The He

Re: [Tutor] prime test problem

2010-08-21 Thread Evert Rol
> Hello, > > I tried it with this simple programm > > def is_prime(n): > x=2 > while x <= int(n**0.5)+1: > if n % x == 0: > return False If your while condition is True, you get into the loop. Inside the loop, however, you never change anything t

Re: [Tutor] prime test problem

2010-08-21 Thread Roelof Wobben
Hello, Thank you. It worked now. x=x+1 must have the same indention als the if then and the return. Roelof > Subject: Re: [Tutor] prime test problem > From: evert@gmail.com > Date: Sat, 21 Aug 2010 19:24:51 +0200 > CC: tutor@python.org > To: rwob...@hotmail.com > > > Hell

Re: [Tutor] Windows Power Shell

2010-08-21 Thread Bill Allen
The very best first feature to learn is the "foreach" command. It elegantly solves the icky, age old, problem in DOS batch of reading in a list of values from a file and doing something with them. This alone sold me completely on WPS. For instance, here is and actual script I used to push an in

Re: [Tutor] prime test problem

2010-08-21 Thread Alan Gauld
"Roelof Wobben" wrote It worked now. x=x+1 must have the same indention als the if then and the return. Or more specifically, it must be indented further than the while statement. The fact thatv the other commands inside the while loop happen to be an if/else is incidental x=1 while x <

Re: [Tutor] design of Point class

2010-08-21 Thread bob gailer
On 8/20/2010 8:35 PM, bob gailer wrote: After yet more thought it gets even more better: I even added a unit test. class PointND(list): def __init__(self, *a_list): super(PointND, self).__init__(a_list) def getSet(ix): def chklen(self): if len(self) < ix + 1: raise At

[Tutor] newline problem

2010-08-21 Thread Roelof Wobben
Hello, I have this programm : def print_digits(n): """ >>> print_digits(13789) 9 8 7 3 1 >>> print_digits(39874613) 3 1 6 4 7 8 9 3 >>> print_digits(213141) 1 4 1 3 1 2 """ count = 0 while n: count = count + 1 n = n / 10

Re: [Tutor] newline problem

2010-08-21 Thread bob gailer
On 8/21/2010 2:36 PM, Roelof Wobben wrote: Hello, I have this programm : def print_digits(n): """ >>> print_digits(13789) 9 8 7 3 1 >>> print_digits(39874613) 3 1 6 4 7 8 9 3 >>> print_digits(213141) 1 4 1 3 1 2 """ count = 0 while n: count = count + 1

[Tutor] monodevelop 2.2

2010-08-21 Thread Thomas
I was wondering if someone could tell me if you can use the gui designer in monodevelop 2.2+ with python. Thanks, Thomas ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tut

Re: [Tutor] monodevelop 2.2

2010-08-21 Thread Emile van Sebille
On 8/21/2010 12:37 PM Thomas said... I was wondering if someone could tell me if you can use the gui designer in monodevelop 2.2+ with python. Searching groups.google.com with "use the gui designer in monodevelop 2.2+ with python" yields a first hit that says "I just used MonoDevelop 2.2 for

Re: [Tutor] Tutor Digest, Vol 78, Issue 97

2010-08-21 Thread Nick
t whether a number is divisible by 3, 5 or 7. > > Then generalise that third program. > > Off you go. Come back when you have some code. Even if it isn't working > code, at least try something. > > > > -- > Steven D'Aprano > __

Re: [Tutor] Tutor Digest, Vol 78, Issue 97

2010-08-21 Thread Steven D'Aprano
Nick, You have replied to a mailing digest containing five different messages. I have NO IDEA what you have to say, because I'm not going to read through all five messages, over 400 lines of text, trying to determine which bits you are commenting on and which bits you are not. You have a delet

Re: [Tutor] Tutor Digest, Vol 78, Issue 99 -- Prime numbers

2010-08-21 Thread Nick
"Perhaps you should try something a little bit less ambitious. Write a program to test whether a number is divisible by 3. Then write a program to test whether a number is divisible by 3 or 5. Then write a third program to test whether a number is divisible by 3, 5 or 7. Then generalise that third

[Tutor] inserting variables into a docstring

2010-08-21 Thread Bill Allen
I am trying to build an HTML body text for an email using a docstring with variables inserted a certain points. It all works just fine, except that the first instance of the variable "pecn" in the HTML link does not get inserted into the text. The second instance of "pecn" gets inserted ok into t

Re: [Tutor] inserting variables into a docstring

2010-08-21 Thread Hugo Arts
On Sat, Aug 21, 2010 at 11:10 PM, Bill Allen wrote: > I am trying to build an HTML body text for an email using a docstring with > variables inserted a certain points.  It all works just fine, except that > the first instance of the variable "pecn" in the HTML link does not get > inserted into the

Re: [Tutor] inserting variables into a docstring

2010-08-21 Thread Bill Allen
On Sat, Aug 21, 2010 at 11:27 PM, Hugo Arts wrote: > > The variable is inserted just fine for me, though there's some > problems with the tag, because you shouldn't surround GET > variables with quotation marks, e.g. you should do this: > > http://example.com/?ecn=423434 > NOT this: > http://exa

Re: [Tutor] Tutor Digest, Vol 78, Issue 99 -- Prime numbers

2010-08-21 Thread Steven D'Aprano
On Sun, 22 Aug 2010 01:54:43 pm Nick wrote: > I was interested in this specific topic as I've been working some > problems on project euler. I've been trying to generate prime numbers > as a first step to go about solving a problem. I don't have a > particular question about solving the problem,

Re: [Tutor] Tutor Digest, Vol 78, Issue 100 -- Prime numbers using square root of n

2010-08-21 Thread Nick
"We're still doing too much work. Why go all the way up to n? We know that (say) 93 can't possibly divide into 99, or 57 into 59. The largest number we need to check is the square root of n. The reason is a little subtle, so think about it, don't just take my word. Hint: write down the factors of,

Re: [Tutor] Tutor Digest, Vol 78, Issue 100 -- Prime numbers using square root of n

2010-08-21 Thread Steven D'Aprano
On Sun, 22 Aug 2010 03:47:21 pm Nick wrote: > Thanks so much Steven. I get it all except I don't think I see the > pattern. I see that we're already covering those higher factors > since they're divisble by 2, 3, 5, etc. I'm just not connecting the > final dot with the square root of n. It's a