[Tutor] random equation generator

2008-10-23 Thread i i
hi, can u tell me any good tutorial site for pygtk, any that contains detail explanation of pygtk. i want to develop a game,that will randomly generate the operands,and the answer,a user have to chosse from the operators(+,-,*,/). which function should i use to randomly generate equation. _

[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] random equation generator

2008-10-23 Thread W W
www.google.com/search?q=pygtk+tutorial www.google.com/search?q=python+random+generator www.google.com/search?q=python+dict If you would like to develop the game, you should first try to develop the game, and then ask when you get stuck. If you can't figure out how to get a user to guess between o

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

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 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 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 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