Re: [Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-04 Thread Matthew Warren
> = > import random > > coin1 = 0 > coin2 = 0 > > coin1 = random.randint(1, 10) > coin2 = random.randint(1, 10) > > if coin1 <= 5: > print "Coin1 is Heads" > else: > print "Coin1 is Tails" > > if coin2 <= 5: > print "Coin2 is Heads" > else: > print "C

Re: [Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-01 Thread Will Shattuck
On 10/1/06, John Fouhy <[EMAIL PROTECTED]> wrote: > On 02/10/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > > or maybe random sample: > > In [22]: random.sample(('heads', 'tails'), 1)[0] > > Out[22]: 'tails' > > I think random.choice would be a better option here: > > >>> random.choice(['heads', 'ta

Re: [Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-01 Thread John Fouhy
On 02/10/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > or maybe random sample: > In [22]: random.sample(('heads', 'tails'), 1)[0] > Out[22]: 'tails' I think random.choice would be a better option here: >>> random.choice(['heads', 'tails']) 'tails' >>> [random.choice(['heads', 'tails']) for i in r

Re: [Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-01 Thread Kent Johnson
Dick Moores wrote: > Works fine, but instead of > coin1 = random.randint(1, 10) > coin2 = random.randint(1, 10) > > you could simplify by using > coin1 = random.randrange(2) > coin2 = random.randrange(2) or maybe random sample: In [22]: random.sample(('heads', 'tails'), 1)[0] Out[22]: 'tails' Ke

Re: [Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-01 Thread Dick Moores
At 04:38 PM 10/1/2006, Will Shattuck wrote: >Hi all, > >I thought that it would be a great idea to learn Python while porting >the BASIC code from this book. So I printed all the pages, have them >"bound" by a big binder clip, and read through the first bit. > >In Chapter 2 there is a type of "Cho

[Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-01 Thread Will Shattuck
Hi all, I thought that it would be a great idea to learn Python while porting the BASIC code from this book. So I printed all the pages, have them "bound" by a big binder clip, and read through the first bit. In Chapter 2 there is a type of "Choose Your Own Adventure" type section. Since I didn