Re: [Tutor] help with random.randint

2010-02-03 Thread Eike Welk
On Wednesday February 3 2010 12:26:43 David wrote: > thanks for the explanation, all this is really helpful -- I certainly > have learned sth. today! > I wonder, though, how I would get my number pairs, which I need later > on, if I were to follow your solution. I am asking because as I > understan

Re: [Tutor] help with random.randint

2010-02-03 Thread Wayne Werner
On Wed, Feb 3, 2010 at 5:26 AM, David wrote: > Hello Eike, > > thanks for the explanation, all this is really helpful -- I certainly have > learned sth. today! > I wonder, though, how I would get my number pairs, which I need later on, > if I were to follow your solution. I am asking because as I

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-03 Thread Wayne Werner
On Wed, Feb 3, 2010 at 12:12 AM, David wrote: > def createQuestions: >generate all multiplication combinations possible >append as tuple to pool >eliminate 'mirrored doubles' (i.e. 7x12 and 12x7) >randomize pool > > I haven't really looked through most of this stuff - but your mir

Re: [Tutor] help with random.randint

2010-02-03 Thread David
Hello Eike, thanks for the explanation, all this is really helpful -- I certainly have learned sth. today! I wonder, though, how I would get my number pairs, which I need later on, if I were to follow your solution. I am asking because as I understand your code, the list terms is a list of int

Re: [Tutor] help with random.randint

2010-02-03 Thread Eike Welk
Hello David! On Wednesday February 3 2010 04:21:56 David wrote: > > import random > terms = [] > for i in range(2): > terms = random.randint(1, 99) > print terms Here is an other solution, which is quite easy to understand and short: import random terms = [] for i in range(2): terms

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-03 Thread spir
On Wed, 03 Feb 2010 14:12:42 +0800 David wrote: > Hello Benno, list, > > thanks for those clarifications, which, well, clarify things ;-) > > This is my latest creation: > > import random > > def createTerms(): > terms = [] > for i in range(2): > terms.append(random.randin

Re: [Tutor] help with random.randint

2010-02-03 Thread spir
On Wed, 03 Feb 2010 11:21:56 +0800 David wrote: > Hello list, > > I thought this was easy even for me, but I was wrong, I guess. > Here is what I want to do: take two random numbers between 1 and 99, and > put them into a list. > > import random > terms = [] > for i in range(2): > terms

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-03 Thread Hugo Arts
On Wed, Feb 3, 2010 at 10:06 AM, David wrote: > Bob, > > brilliant stuff -- I am truly awed by this. Create a default-filled matrix > and mark combinations used so as to take them out of the game? Wow. This is > new to me. > > On 03/02/10 15:46, bob gailer wrote > >> def askQuestions(): # generate

Re: [Tutor] help with random.randint

2010-02-03 Thread Hugo Arts
On Wed, Feb 3, 2010 at 8:19 AM, David wrote: > Hello Bob, > > thanks for your comments! > > > On 03/02/10 14:51, bob gailer wrote: > >> or if you seek terseness: >> >> terms = [random.randint(1, 99) for i in 'ab'] > > Do I understand correctly that 'ab' here merely serves to produce a 'dummy > seq

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-03 Thread David
Bob, brilliant stuff -- I am truly awed by this. Create a default-filled matrix and mark combinations used so as to take them out of the game? Wow. This is new to me. On 03/02/10 15:46, bob gailer wrote def askQuestions(): # generate and ask questions: for i in range(NQ): while 1: # loop ti

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-02 Thread bob gailer
David wrote: [snip] My suggestion (untested): MAX = 12 NQ = 20 # of questions to ask # create a 2 dimensional array of 1's row = [1]*MAX pool = [row[:] for i in range(MAX)] incorrect = [] # store incorrectly answered combos here def askQuestions(): # generate and ask questions: for i in r

Re: [Tutor] help with random.randint

2010-02-02 Thread David
Hello Bob, thanks for your comments! On 03/02/10 14:51, bob gailer wrote: or if you seek terseness: terms = [random.randint(1, 99) for i in 'ab'] Do I understand correctly that 'ab' here merely serves to produce a 'dummy sequence' over which I can run the for loop? David __

Re: [Tutor] help with random.randint

2010-02-02 Thread bob gailer
David wrote: Hello list, I thought this was easy even for me, but I was wrong, I guess. Here is what I want to do: take two random numbers between 1 and 99, and put them into a list. [snip] Or you can use list comprehension: terms = [random.randint(1, 99) for i in range(2)] or if you seek

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-02 Thread David
Hello Benno, list, thanks for those clarifications, which, well, clarify things ;-) This is my latest creation: import random def createTerms(): terms = [] for i in range(2): terms.append(random.randint(1, 99)) j = terms[0] k = terms[1] print "%3d\nx%2d" % (j, k)

Re: [Tutor] help with random.randint

2010-02-02 Thread Benno Lang
On Wed, Feb 3, 2010 at 12:21 PM, David wrote: > Hello list, > > I thought this was easy even for me, but I was wrong, I guess. > Here is what I want to do: take two random numbers between 1 and 99, and put > them into a list. > > import random > terms =  [] > for i in range(2): >        terms = ra

[Tutor] help with random.randint

2010-02-02 Thread David
Hello list, I thought this was easy even for me, but I was wrong, I guess. Here is what I want to do: take two random numbers between 1 and 99, and put them into a list. import random terms = [] for i in range(2): terms = random.randint(1, 99) print terms This prints just one number