Re: [Tutor] Need help with script for finding pairs of amicable numbers

2010-11-17 Thread Richard D. Moores
I got no response to my post that began this thread 8 days ago. I followed that with a new thread, "List comprehension question" that continued for 60+ posts, and from which I learned a lot -- about optimizing a function (and the importance of timing the various candidates for improvement). The fun

[Tutor] Need help with script for finding pairs of amicable numbers

2010-11-10 Thread col speed
> > -- > > Message: 2 > Date: Tue, 09 Nov 2010 12:35:26 +0100 > From: Stefan Behnel > To: tutor@python.org > Subject: Re: [Tutor] List comprehension question > Message-ID: > Content-Type: text/plain; charset=UTF-8; format=flowed > > Richard D. Moores, 09.11.2010 12:07:

[Tutor] Need help with script for finding pairs of amicable numbers

2010-11-09 Thread Richard D. Moores
Here's what I have so far: . My immediate question is, is there a general way to determine the multiplier of n in line 44? Of course, by trial and error I can find out pretty exactly what it should be to find a pair that I know of. But of course I want to go o

Re: [Tutor] Need help with converting script using 2.6's urllib2 to Python 3.1

2010-10-25 Thread Richard D. Moores
So I finally find a relevant example in the docs: The first example gave me some understanding and led me to revising my code to import urllib.request f = urllib.request.urlopen('http://www.marketwatch.com/invest

Re: [Tutor] Need help with converting script using 2.6's urllib2 to Python 3.1

2010-10-25 Thread Sander Sweers
On 25 October 2010 18:19, Richard D. Moores wrote: > Doing it your way, > > from urllib import request > a = > request.urlopen('http://www.marketwatch.com/investing/currency/CUR_USDYEN').read(20500) > print(a[123:140]) > > succeeds. Why? Not sure how this exactly works but this is what I know. T

Re: [Tutor] Need help with converting script using 2.6's urllib2 to Python 3.1

2010-10-25 Thread Richard D. Moores
And trying 2to3.py, which I've used successfully before, gets C:\P26Working\Finished\For2to3>2to3 -w -f urllib dollar2yen_rate_simple.py Traceback (most recent call last): File "C:\P26Working\Finished\For2to3\2to3.py", line 2, in from lib2to3.main import main File "C:\P26Working\Finished\

Re: [Tutor] Need help with converting script using 2.6's urllib2 to Python 3.1

2010-10-25 Thread Richard D. Moores
On Mon, Oct 25, 2010 at 08:38, Sander Sweers wrote: > Have you actually tried reading the documentation? Of course. Though I can see why you wondered. >The _very_ first > section of the urllib documentation we have urllib.request.urlopen > [1]. Which looks to me what you are looking for as a re

Re: [Tutor] Need help with converting script using 2.6's urllib2 to Python 3.1

2010-10-25 Thread Sander Sweers
On 25 October 2010 14:46, Richard D. Moores wrote: > I'd like to convert the script to 3.1, but I can't understand the docs > for the 3.1 urllib module. Please someone tell me what to do. > (Converting   'print rate'   to   'print(rate)'   I understand.) Have you actually tried reading the docume

[Tutor] Need help with converting script using 2.6's urllib2 to Python 3.1

2010-10-25 Thread Richard D. Moores
The lines below are the essence of a 2.6 script that gets the current USD/yen quote. I'd like to convert the script to 3.1, but I can't understand the docs for the 3.1 urllib module. Please someone tell me what to do. (Converting 'print rate' to 'print(rate)' I understand.) import urllib2

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Steven D'Aprano
On Wed, 18 Aug 2010 09:21:51 pm Laurens Vets wrote: > On 8/12/2010 1:26 AM, Steven D'Aprano wrote: > > On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: > >> I need to generate a list of 30 numbers randomly chosen from 1, 2, > >> 3, 4, 5& 6. However, I cannot have more than 2 numbers which are >

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Dave Angel
Laurens Vets wrote: Yes of course :) That's a typo on my part. I came up with the following which I think works as well? import random reeks = [] for i in range(60): temp = [random.randint(1, 6)] while reeks[-2:-1] == reeks[-1:] == temp: temp = [random.randint(1, 6)] if reeks.

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Laurens Vets
Thank you all for your help! I've added another condition to this program, namely, in a range of 60, each 'random' number can only occur 10 times. I came up with the following: import random series = [] for i in range(60): temp = [random.randint(1, 6)] while series[-2:-1] == series[-1:

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Evert Rol
On 18 Aug 2010, at 13:21 , Laurens Vets wrote: > On 8/12/2010 1:26 AM, Steven D'Aprano wrote: >> On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: >> >>> I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, >>> 4, 5& 6. However, I cannot have more than 2 numbers which are the

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Laurens Vets
On 8/12/2010 1:26 AM, Steven D'Aprano wrote: On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5& 6. However, I cannot have more than 2 numbers which are the same next to each other. I came up with the following (Please

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Alan Gauld
"Laurens Vets" wrote next to each other. I came up with the following (Please ignore the fact that I'm trying to avoid an IndexError in a stupid way :)): Others have answered your question. I'll suggest that instead of using indexes its easier to just cache the last two values in variable

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Steven D'Aprano
On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: > I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, > 4, 5 & 6. However, I cannot have more than 2 numbers which are the > same next to each other. I came up with the following (Please ignore > the fact that I'm trying to avo

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Emile van Sebille
On 8/11/2010 2:04 PM Laurens Vets said... Hello list, I'm learning Python and I'm currently facing an issue with a small script I'm writing. I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & 6. However, I cannot have more than 2 numbers which are the same next to each

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Evert Rol
> I'm learning Python and I'm currently facing an issue with a small script I'm > writing. > > I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & > 6. However, I cannot have more than 2 numbers which are the same next to each > other. I came up with the following (Plea

[Tutor] Need help understanding output...

2010-08-11 Thread Laurens Vets
Hello list, I'm learning Python and I'm currently facing an issue with a small script I'm writing. I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & 6. However, I cannot have more than 2 numbers which are the same next to each other. I came up with the following (P

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
On Tue, Jul 27, 2010 at 07:51, Nick Raptis wrote: > On 07/27/2010 05:22 PM, Richard D. Moores wrote: > >> Python 3.1 on Vista. >> >> Please see . >> >> I'm trying to recall what I used to know, thus this simple script. But 'y' >> or 'q' do nothing. What's wr

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
On Tue, Jul 27, 2010 at 09:09, Alan Gauld wrote: > > "Richard D. Moores" wrote > > > Please see . >> >> I'm trying to recall what I used to know, thus this simple script. But 'y' >> or 'q' do nothing. What's wrong? >> > > I don't think you need kbhit() I

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Alan Gauld
"Richard D. Moores" wrote Please see . I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? I don't think you need kbhit() or the sleep(.1) The if kbhit test will only pass if the key is actually

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
On Tue, Jul 27, 2010 at 07:51, Nick Raptis wrote: > On 07/27/2010 05:22 PM, Richard D. Moores wrote: > >> Python 3.1 on Vista. >> >> Please see . >> >> I'm trying to recall what I used to know, thus this simple script. But 'y' >> or 'q' do nothing. What's wr

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
On Tue, Jul 27, 2010 at 07:36, Tim Golden wrote: > On 27/07/2010 15:22, Richard D. Moores wrote: > >> Python 3.1 on Vista. >> >> Please see. >> >> I'm trying to recall what I used to know, thus this simple script. But 'y' >> or 'q' do nothing. What's wrong?

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Nick Raptis
On 07/27/2010 05:22 PM, Richard D. Moores wrote: Python 3.1 on Vista. Please see . I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? Thanks, Dick Moores Hi Dick! I'm not on Windows here so

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Tim Golden
On 27/07/2010 15:22, Richard D. Moores wrote: Python 3.1 on Vista. Please see. I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? msvcrt.getch returns bytes on Python 3.1; you're comparing against

[Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
Python 3.1 on Vista. Please see . I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? Thanks, Dick Moores ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] Need help with functions!

2010-01-26 Thread Alan Gauld
"Raymond Kwok" wrote I have a function called get_word() that does the random word thing and returns two things - 1) original word and 2) scrambled word, jumble = get_word()[0] originalword = get_word()[1] You need to store the return value once and access the two values. words = get_wor

[Tutor] Need help with functions!

2010-01-25 Thread Raymond Kwok
Hello all, I have started to learn Python a few months ago and I'm loving it! I am creating a mini-game - the one that scrambles an English word and asks you what the originalword should be, e.g. yhptno ---> python So, I have a function called get_word() that does the random word thing and retu

Re: [Tutor] need help in python

2010-01-21 Thread Robert
And your question is ? On Thu, Jan 21, 2010 at 12:48 PM, invincible patriot wrote: > hi > I am a student and i need soe help regarding my assignmentif some one can > help me il be glad. > > i wil be waiting for the reply > > thanks > > ___ Tutor mailli

Re: [Tutor] need help in python

2010-01-21 Thread Luke Paireepinart
Don't post messages to the list in reply to other messages, it messes up threading. Other than that, you'll have to tell us more about your assignment if you want help. -Luke On Thu, Jan 21, 2010 at 11:48 AM, invincible patriot < invincible_patr...@hotmail.com> wrote: > hi > I am a student and i

Re: [Tutor] need help in python

2010-01-21 Thread Andreas Kostyrka
Am Donnerstag, 21. Januar 2010 18:48:36 schrieb invincible patriot: > hi > I am a student and i need soe help regarding my assignmentif some one can > help me il be glad. You do realize that assignments are things to be done by yourself? This is a mailing list, so just post your questions, but d

[Tutor] need help in python

2010-01-21 Thread invincible patriot
hi I am a student and i need soe help regarding my assignmentif some one can help me il be glad. i wil be waiting for the reply thanks Date: Thu, 21 Jan 2010 12:33:40 -0500 From: samueldechampl...@gmail.com To: tutor@python.org Subject: [Tutor] Hello This is my first message to this mailing

[Tutor] Need help, tutoring Python

2010-01-21 Thread Neal Mendelsohn
I am looking for someone who knows WordPress to spend an hour with me on the phone and with a shared screen to coach me on how WordPress can be configured using Python files. Can you refer me? Thanks, NM ___ Tutor maillist - Tutor@python.org To uns

Re: [Tutor] need help with 3.1's fraction module

2010-01-06 Thread Richard D. Moores
On Wed, Jan 6, 2010 at 11:59, bob gailer wrote: > Fraction(str(random())).limit_denominator(100) Thanks! So here's what I wanted to do, or its beginning: == from fractions import Fraction from random import random r = random() print(r) f = str(Fraction(str(r)).limit_denomi

Re: [Tutor] need help with 3.1's fraction module

2010-01-06 Thread bob gailer
Richard D. Moores wrote: from fractions import Fraction Fraction('.83452345').limit_denominator(100) Fraction(81, 97) I'd like to know how to do that in a script, where numbers like .83452345 are the output of random.random(). Fraction(random()).limit_denominator(100) Do

[Tutor] need help with 3.1's fraction module

2010-01-06 Thread Richard D. Moores
>>> from fractions import Fraction >>> Fraction('.83452345').limit_denominator(100) Fraction(81, 97) I'd like to know how to do that in a script, where numbers like .83452345 are the output of random.random(). >>> Fraction(random()).limit_denominator(100) Doesn't work, nor did I really expect it

Re: [Tutor] need help with conditionals

2009-09-26 Thread kevin parks
On Sep 26, 2009, at 11:42 PM, Alan Gauld wrote: "Kent Johnson" wrote It appears to be http://openbookproject.net/thinkCSpy/ch04.html So it is, Thats a shame CSpy is one of my favourite "competitors" :-) Pity it's apparently encouraging the use of eval like this with no caveat. But to

Re: [Tutor] need help with conditionals

2009-09-26 Thread Kent Johnson
On Sat, Sep 26, 2009 at 3:59 AM, Alan Gauld wrote: > What are you using for a tutorial? It appears to be http://openbookproject.net/thinkCSpy/ch04.html Kent ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://m

Re: [Tutor] need help with conditionals

2009-09-26 Thread Alan Gauld
"Kent Johnson" wrote It appears to be http://openbookproject.net/thinkCSpy/ch04.html So it is, Thats a shame CSpy is one of my favourite "competitors" :-) Pity it's apparently encouraging the use of eval like this with no caveat. But to the OP, keep with it, its not a bad tutorial, shame

Re: [Tutor] need help with conditionals

2009-09-26 Thread Alan Gauld
wrote been really frustrating me. Here's a copy of the problem, and sorry if its really long but its the end question about the logically equivalent expressions I'm stuck on. Anyways, heres a copy of the problem First send us the real code you have used not a copy of your homework. And se

Re: [Tutor] need help with conditionals

2009-09-25 Thread Lie Ryan
wrobl...@cmich.edu wrote: Hello all, I am still very new to Python and am working on conditionals. Im stuck on this problem and I'm sorry if this is something really simple that I'm missing but its been really frustrating me. Here's a copy of the problem, and sorry if its really long but its t

Re: [Tutor] need help with conditionals

2009-09-25 Thread christopher . henk
> Hello all, > I am still very new to Python and am working on conditionals. Im stuck on this > problem and I'm sorry if this is something really simple that I'm missing but its > been really frustrating me. Here's a copy of the problem, and sorry if its really > long but its the end questio

[Tutor] need help with conditionals

2009-09-25 Thread wrobl1rt
Hello all, I am still very new to Python and am working on conditionals. Im stuck on this problem and I'm sorry if this is something really simple that I'm missing but its been really frustrating me. Here's a copy of the problem, and sorry if its really long but its the end question about the

Re: [Tutor] need help

2009-08-06 Thread Alan Gauld
"jonathan wallis" wrote from pygame.locals import * from pygame.color import THECOLORS if not pygame.font: print 'Atention, there are no fonts.' if not pygame.mixer: print 'Atention, there is no sound.' pygame.init() blue = (0, 0, 255) red = (255, 0, 0) black = (0, 0, 0) window_widt

[Tutor] need help

2009-08-06 Thread jonathan wallis
i am in the process of creating a simple python program, and i have come across a problem which i can not solve, here is the code *import pygame from pygame.locals import * from pygame.color import THECOLORS if not pygame.font: print 'Atention, there are no fonts.' if not pygame.mixer:

Re: [Tutor] Need help in making this code more pythonic

2009-07-26 Thread Rich Lovely
> --- On Sun, 7/26/09, ammar azif wrote: > > From: ammar azif > Subject: [Tutor] Need help in making this code more pythonic > To: tutor@python.org > Date: Sunday, July 26, 2009, 6:23 AM > > Hello, > > I need some suggestions on how to make this code pythonic.

Re: [Tutor] Need help in making this code more pythonic

2009-07-26 Thread ammar azif
Sorry I forgot to attach the code file. Here it is. --- On Sun, 7/26/09, ammar azif wrote: From: ammar azif Subject: [Tutor] Need help in making this code more pythonic To: tutor@python.org Date: Sunday, July 26, 2009, 6:23 AM Hello, I need some suggestions on how to make this code pythonic

[Tutor] Need help in making this code more pythonic

2009-07-26 Thread ammar azif
Hello, I need some suggestions on how to make this code pythonic. The program basically runs a simulation of an object that moves on a 2D plane. The object keeps on moving from its current coordinate to  randomly picked adjacent coordinates with the object is not allowed to move move to a previ

Re: [Tutor] Need help with python game program

2009-07-02 Thread Lie Ryan
Luke Paireepinart wrote: > Please don't reply to messages like this. If you are starting a new > thread, send a new e-mail to tutor@python.org . > DO NOT start a thread by replying to another message. If you do, it > will bork on people's machines who use threaded e-mail

Re: [Tutor] Need help with python game program

2009-06-30 Thread Dave Angel
jonathan wallis wrote: My problem is simple, is their a way to make a variable equal multiple numbers? Such as X = 5 through 10, and then the program makes x equal something random 5 through 10, or something similar. For a short question, why did you quote an entire mailing list digest?

Re: [Tutor] Need help with python game program

2009-06-30 Thread Luke Paireepinart
Please don't reply to messages like this. If you are starting a new thread, send a new e-mail to tu...@python.org. DO NOT start a thread by replying to another message. If you do, it will bork on people's machines who use threaded e-mail readers. also, please remove long, irrelevant quotations

Re: [Tutor] Need help with python game program

2009-06-30 Thread Mark Tolonen
"jonathan wallis" wrote in message news:57b8984c0906301738w1fb0e660m6bb2123399f27...@mail.gmail.com... My problem is simple, is their a way to make a variable equal multiple numbers? Such as X = 5 through 10, and then the program makes x equal something random 5 through 10, or something simil

[Tutor] Need help with python game program

2009-06-30 Thread jonathan wallis
My problem is simple, is their a way to make a variable equal multiple numbers? Such as X = 5 through 10, and then the program makes x equal something random 5 through 10, or something similar. 2009/6/30 > Send Tutor mailing list submissions to >tutor@python.org > > To subscribe or unsu

Re: [Tutor] Need help with code.

2009-06-19 Thread Dave Angel
Raj Medhekar wrote: Hi, I need help with the code below. I am trying to pair the list in the hint with the list of words. However, the list is not matching up correctly. Also when the correct guess is entered the program just continues without acknowledging the right answer. Please could y'al

Re: [Tutor] Need help with code.

2009-06-19 Thread bob gailer
Raj Medhekar wrote: Hi, I need help with the code below. I am trying to pair the list in the hint with the list of words. However, the list is not matching up correctly. Also when the correct guess is entered the program just continues without acknowledging the right answer. Please could y'all

[Tutor] Need help with code.

2009-06-19 Thread Raj Medhekar
Hi, I need help with the code below. I am trying to pair the list in the hint with the list of words. However, the list is not matching up correctly. Also when the correct guess is entered the program just continues without acknowledging the right answer. Please could y'all test this out and let

Re: [Tutor] Need help solving this problem

2009-06-10 Thread ayyaz
Raj Medhekar wrote: I have been teaching myself Python using a book. The chapter I am on currently, covers branching, while loops and program planning. I am stuck on on of the challenges at the end of this chapter, and I was hoping to get some help with this. Here it is: Write a program that

Re: [Tutor] Need help solving this problem

2009-06-10 Thread Alan Gauld
"Raj Medhekar" wrote Write a program that flips a coin 100 times and the tells you the number of heads and tails. I have tried to think about several ways to go about doing this but I have hit a wall. Even though I understand the general concept of branching and looping, I have been having

Re: [Tutor] Need help solving this problem

2009-06-10 Thread David
Raj Medhekar wrote: I have been teaching myself Python using a book. The chapter I am on currently, covers branching, while loops and program planning. I am stuck on on of the challenges at the end of this chapter, and I was hoping to get some help with this. Here it is: Write a program that

Re: [Tutor] Need help solving this problem

2009-06-10 Thread karma
Hi Raj, I'm another learner, I used the following: >>> def toss(n): heads = 0 for i in range(n): heads += random.randint(0,1) return heads, n-heads >>> print "%d heads, %d tails" % toss(100) Best of luck in your python endeavors! 2009/6/10 Raj Medhekar :

Re: [Tutor] Need help solving this problem

2009-06-10 Thread Robert Berman
What you are looking at is a simulation whereby a coin having 2 outcomes (heads or tails) is flipped exactly 100 times. You need to tell how many times the coin falls heads up and how many times the coin falls tails up. First become familiar with the random module. Assign a value of 1 for heads a

Re: [Tutor] Need help solving this problem

2009-06-10 Thread Albert-jan Roskam
): if draw() == ["head"]: heads += 1 else: tails += 1 return heads, tails for attempt in range(20): print "attempt:", attempt+1, "heads:", toss()[0], "tails:", toss()[1] --- On Wed, 6/10/09, Raj Medhekar wrote: > From: Raj Medhek

[Tutor] Need help solving this problem

2009-06-10 Thread Raj Medhekar
I have been teaching myself Python using a book. The chapter I am on currently, covers branching, while loops and program planning. I am stuck on on of the challenges at the end of this chapter, and I was hoping to get some help with this. Here it is: Write a program that flips a coin 100 times

Re: [Tutor] need help opening a file in idle

2009-05-24 Thread Alan Gauld
"Meital Amitai" wrote I am not sure how to open a file in my computer in idle. You need to be clear what you are doing. You are not opening the file in IDLE you are opening the file in Python. IDLE is just the tool you use to write Ptython programs. For my python class the homework states t

Re: [Tutor] need help opening a file in idle

2009-05-23 Thread bob gailer
Meital Amitai wrote: Hi everyone, I am not sure how to open a file in my computer in idle. For my python class the homework states to write a function that accepts the name of a file and returns a tuple containing the number of lines, words and characters in the file. My problem is how do I g

[Tutor] need help opening a file in idle

2009-05-23 Thread Meital Amitai
Hi everyone, I am not sure how to open a file in my computer in idle. For my python class the homework states to write a function that accepts the name of a file and returns a tuple containing the number of lines, words and characters in the file. My problem is how do I get idle to first accept t

Re: [Tutor] Need help with registry access

2009-05-08 Thread Tim Golden
ALAN GAULD wrote: The _winreg module is part of the standard library and provides functions for accessing the Windows registry. There's some (incomplete) help here, but as Alan said, you need to learn Python to some extent before trying to do this. http://timgolden.me.uk/python-on-windows/pro

Re: [Tutor] Need help with registry access

2009-05-08 Thread ALAN GAULD
/NonProgrammers http://docs.python.org/tutorial/ Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Original Message > From: Christopher Barkley > To: Alan Gauld > Sent: Friday, 8 May, 2009 5:09:25 AM > Subject: Re: [Tutor] Need help with reg

Re: [Tutor] Need help with registry access

2009-05-07 Thread Lie Ryan
spir wrote: Le Fri, 8 May 2009 01:20:32 +0100, "Alan Gauld" s'exprima ainsi: "Christopher Barkley" wrote My friend and I are techies, he's on my LAN. I want to disable his keyboard through the registry (or some other fun way) while he's in the middle of playing starcraft by running a scri

Re: [Tutor] Need help with registry access

2009-05-07 Thread spir
Le Fri, 8 May 2009 01:20:32 +0100, "Alan Gauld" s'exprima ainsi: > > "Christopher Barkley" wrote > > > My friend and I are techies, he's on my LAN. I want to disable > > his keyboard through the registry (or some other fun way) > > while he's in the middle of playing starcraft by running a

Re: [Tutor] Need help with registry access

2009-05-07 Thread Alan Gauld
"Christopher Barkley" wrote My friend and I are techies, he's on my LAN. I want to disable his keyboard through the registry (or some other fun way) while he's in the middle of playing starcraft by running a script through the LAN. Look at the winreg module for accessing the registry. H

[Tutor] Need help with registry access

2009-05-07 Thread Christopher Barkley
Python 3.0.1 Windows XP PROFESSIONAL, SP3 Looking for help manipulating the registry through python. Heres what I'm wanting to do. My friend and I are techies, he's on my LAN. I want to disable his keyboard through the registry (or some other fun way) while he's in the middle of playing starcr

Re: [Tutor] Need help w/ a for loop

2008-10-24 Thread Kent Johnson
On Fri, Oct 24, 2008 at 6:51 AM, W W <[EMAIL PROTECTED]> wrote: > for i in range(1, n+1): > x = x + (m * (i % 2)) * (4.0/(i*2)) This will omit every other term (when i%2 ==0) and it divides by the even numbers, not odd ones. Kent ___ Tutor maillist

Re: [Tutor] Need help w/ a for loop

2008-10-24 Thread W W
On Thu, Oct 23, 2008 at 10:29 PM, Monte Milanuk <[EMAIL PROTECTED]> wrote: > Hello again, and thanks to all of you who extended your help! > Maybe I'm not clever enough, but I didn't see how either example > could be used for doing the addition/subtraction determination. Or rather, > I found a di

Re: [Tutor] Need help w/ a for loop

2008-10-24 Thread Monte Milanuk
Hello again, and thanks to all of you who extended your help! Wayne, Thanks for your examples. They did end up helping in with finding a pattern to do the odd numbers with. Maybe I'm not clever enough, but I didn't see how either example could be used for doing the addition/subtraction determ

Re: [Tutor] Need help w/ a for loop

2008-10-23 Thread Kent Johnson
On Thu, Oct 23, 2008 at 10:20 AM, bob gailer <[EMAIL PROTECTED]> wrote: > import operator > ops = (operator.add, operator.sub) > x = 0 > m = 0 > for in in range... > x = ops[m](x, 4.0/i) > m = 1-m itertools.cycle(ops) is handy here. Hmm, there is a cute one-line solution (excluding import an

Re: [Tutor] Need help w/ a for loop

2008-10-23 Thread Richard Lovely
Why not throw in itertools.cycle while you're at it? ;-) pi = sum(4. / (1+x) * itertools.cycle((1,-1)).next() for x in range(0, 4 * n, 2)) I'd also be so tempted just to call the file 'approximate' (read it with extension...) Let's also not forget about integer division... 2008/10/23 bob gailer

Re: [Tutor] Need help w/ a for loop

2008-10-23 Thread bob gailer
Monte Milanuk wrote: Hello all, New guy here, so go easy on me ;) We save the whips and chains for the more hardened questers. Newcomers get the feathers. I'm starting to work my way through Python Programming by Zelle, and have hit a bit of a wall on one of the prog

Re: [Tutor] Need help w/ a for loop

2008-10-23 Thread Kent Johnson
On Thu, Oct 23, 2008 at 12:09 AM, Monte Milanuk <[EMAIL PROTECTED]> wrote: > def main(): > print "This program will approximate the value of pi" > print "to a degree determined by the user. " > print > > # get the value of n from the user > n = input("How many terms do you wan

Re: [Tutor] Need help w/ a for loop

2008-10-23 Thread W W
On Wed, Oct 22, 2008 at 11:09 PM, Monte Milanuk <[EMAIL PROTECTED]> wrote: > Hello all, > > New guy here, so go easy on me ;) > Welcome to python and the tutor list! > I'm starting to work my way through Python Programming by Zelle, and have > hit a bit of a wall on one of the programming exerc

[Tutor] Need help w/ a for loop

2008-10-23 Thread Monte Milanuk
Hello all, New guy here, so go easy on me ;) I'm starting to work my way through Python Programming by Zelle, and have hit a bit of a wall on one of the programming exercises in Chapter 3 (#15 if anyone has the book handy). What the question ask is: Write a program that approimates the valu

Re: [Tutor] Need help with using methods in a base class

2008-09-08 Thread Kent Johnson
On Mon, Sep 8, 2008 at 9:21 AM, Roy Khristopher Bayot <[EMAIL PROTECTED]> wrote: > Hi. It worked. :-) class LightsHandle(Parallel): > ... def __init__(self): > ... Parallel.__init__(self) > ... def __del__(self): > ... Parallel.__del__(self) These two methods

Re: [Tutor] Need help with using methods in a base class

2008-09-08 Thread Roy Khristopher Bayot
Hi. It worked. >>> class LightsHandle(Parallel): ... def __init__(self): ... Parallel.__init__(self) ... def __del__(self): ... Parallel.__del__(self) ... def setLatch(self, x, y, z): ... self.setDataStrobe(x) ... print 'Data Strobe set.

Re: [Tutor] Need help with using methods in a base class

2008-09-07 Thread Kent Johnson
On Sun, Sep 7, 2008 at 11:07 AM, Roy Khristopher Bayot <[EMAIL PROTECTED]> wrote: > Hi. I added self to parts of the code. But after making an instance and > using the setData method it gave out an AttributeError. > from parallel import Parallel class LightsHandle(Parallel): > ... def

Re: [Tutor] Need help with using methods in a base class

2008-09-07 Thread Roy Khristopher Bayot
Hi. I added self to parts of the code. But after making an instance and using the setData method it gave out an AttributeError. >>> from parallel import Parallel >>> class LightsHandle(Parallel): ... def __init__(self): ... pass ... def setData(self, data): ... Para

Re: [Tutor] Need help with using methods in a base class

2008-09-06 Thread Alan Gauld
"Roy Khristopher Bayot" <[EMAIL PROTECTED]> wrote ... def generateClockPulse(self): ... parallel.Parallel.setSelect(0) ... parallel.Parallel.setSelect(1) ... a = LightsHandle() a.setD(0xF0) Traceback (most recent call last): File "", line 1, in File "", line 5,

Re: [Tutor] Need help with using methods in a base class

2008-09-06 Thread Kent Johnson
On Sat, Sep 6, 2008 at 12:04 PM, Roy Khristopher Bayot <[EMAIL PROTECTED]> wrote: > Hi. I am having some difficulty using methods from a base class. > > I have 2 classes. The first one is Parallel which is inside the module > parallel. The methods useful to me from this class are setDataStrobe(), >

[Tutor] Need help with using methods in a base class

2008-09-06 Thread Roy Khristopher Bayot
Hi. I am having some difficulty using methods from a base class. I have 2 classes. The first one is Parallel which is inside the module parallel. The methods useful to me from this class are setDataStrobe(), setAutoFeed(), setInitOut(), setSelect(), and setData(). The second one is derived from t

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-05 Thread Terry Carroll
On Fri, 5 Sep 2008, Terry Carroll wrote: > On Sat, 6 Sep 2008, John Fouhy wrote: > > > You can count the number of fives in the prime decomposition of a > > number by just dividing by 5 repeatedly until you don't get a whole > > number. > > But that requires having the number first, doesn't it?

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-05 Thread Terry Carroll
On Sat, 6 Sep 2008, John Fouhy wrote: > 2008/9/5 Terry Carroll <[EMAIL PROTECTED]>: > > So here's my routine to address the problem. It consists of making a > > multiplication table of coefficients that includes the factor such as 5, > > 25, 125, etc., and their values (1, 6, 31, etc). Then, sta

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-05 Thread John Fouhy
2008/9/5 Terry Carroll <[EMAIL PROTECTED]>: > So here's my routine to address the problem. It consists of making a > multiplication table of coefficients that includes the factor such as 5, > 25, 125, etc., and their values (1, 6, 31, etc). Then, starting with the > highest ones first, successiev

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-05 Thread Robert Berman
Wow. What a group. Terry, don't feel bad about the answer. I already derived it using all the information I got yesterday. Your solution is a very nice addition to what I learned, and I appreciate that very much. Again, thanks to everyone who provided hints, equations, proofs, and logic paths

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Terry Carroll
On Thu, 4 Sep 2008, Robert Berman wrote: > Time to do some reading about regex. And here I thought I was slick > working with lists and strings. You shouldn't need a regexp for this. An easy way to count the trailing zeros is: - convert the number to a string; - make a copy, stripping off the

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Terry Carroll
On Thu, 4 Sep 2008, Robert Berman wrote: > "It can easily be seen that 6! = 720 and has exactly one > trailing zero. What is the lowest integer, x, such that x! has 7^20 > trailing zeros?" > > It does not, on the surface, appear to be a frontal lobe breaker. Design > an algorithm to build factori

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
Chris, Thank you very much for this. It is very helpful. I will check my answer against yours in the morning. Robert Chris Fuller wrote: I spent the day mulling over this problem, and then implemented my solution when I got home. This is for the easier problem of 7**8 zeros: On my linux

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Chris Fuller
I spent the day mulling over this problem, and then implemented my solution when I got home. This is for the easier problem of 7**8 zeros: On my linux box, running something around 2 GHz, my script runs for about two minutes and the answer is 23059225. You can verify your code to that. I ch

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
Thank you  very much for the help and the math explanation from Omer.  Much of my math background is based on  brute force methodology. Obviously, things have changed. Really changed. Time to do some reading about regex. And here I thought I was slick working with lists and strings. Robert

[Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
I am using both the THINK PYTHON text and the Challenge-You website to learn Python. I am doing reasonably well and certainly enjoy the available challenges. I am currently attempting to work a challenge known as the 'Zeros of a Factorial' challenge located at http://www.challenge-you.com/ch

Re: [Tutor] need help; save web data

2008-06-30 Thread W W
On Sun, Jun 29, 2008 at 2:28 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Note that this may be a violation of the Google Scholar terms of > service; I know it is a violation to automatically collect normal > Google search results, and IIRC Google takes some steps to make it > difficult as well.

<    1   2   3   4   5   6   >