Hi Max and everyone,

Max, your reply-to only went to me.  You have to work harder to get it to
go to the whole list.

Anyway, my advice is to post your new program and see what people say.

Marilyn

---------------------------- Original Message ----------------------------
Subject: Re: [Tutor] powerball
From:    "max baseman" <[EMAIL PROTECTED]>
Date:    Wed, June 11, 2008 7:22 pm
To:      "Marilyn Davis" <[EMAIL PROTECTED]>
--------------------------------------------------------------------------

thank you for your help i beleave i have fixed this bug and made the
script slightly shorter yet i seem to have run into another bug i
cant find - the program now just eats my ram and doesn't seem to run
correctly now it displays no output and nearly freezes my computer
i'm still looking for the reason but if you have the time i would
appreciate you advise

- thanks





On Jun 11, 2008, at 12:36 PM, Marilyn Davis wrote:

> On Wed, June 11, 2008 9:58 am, max baseman wrote:
>
> Hi Max,
>
> Here's your code with the indents preserved.  I'll make my comments
> with >'s.
>
> from random import randrange
> wins=0
> win=[]
> count =0
> while count !=5:
>
>>  To loop 5 times it is better to use:
>
>>  for count in range(5):
>>       stuff you want to do
>
>>  Then all the loop controlling happens in one place and it is hard to
>>  mess up.
>
>      number=randrange(55)+1
>      win.append(number)
>      count=count+1
> powerball=randrange(42)+1
> count=0
> win.sort()
> while count !=146107962:
>      numbers=[]
>      count2=0
>      while count2 !=5:
>          number=randrange(55)+1
>
>>  Yep, indeed, here you made the easy mistake of forgetting to + 1 to
>>  count2.  So, it probably spun forever right there.
>
>>  I also don't see that "count" is every changed, so that would be
>> another
>>  spin.  All these would go away by using 'for' 'in' and 'range'.
>
>>  It looks like a fun program and a good start.
>
>>  Marilyn Davis
>
>      if number in win:
>          numbers.append(number)
>      else:
>          print "lose"
>          break
>      numbers.sort()
>      ball=randrange(42)+1
>      if ball==powerball:
>          print "win"
> print
> print
> print win, powerball
>
>> as a fun little project i scripted a powerball program. it seems
>> to have a
>> bug in it that i cant find.
>>
>> from random import randrange wins=0 win=[] count =0 while count !=5:
>> number=randrange(55)+1 win.append(number) count=count+1
>> powerball=randrange(42)+1 count=0 win.sort() while count !=146107962:
>> numbers=[] count2=0 while count2 !=5: number=randrange(55)+1 if
>> number in
>> win:
>> numbers.append(number) else:
>> print "lose" break numbers.sort() ball=randrange(42)+1 if
>> ball==powerball:
>> print "win" print print print win, powerball
>>
>>
>>
>>
>> _______________________________________________
>> Tutor maillist  -  [email protected]
>> http://mail.python.org/mailman/listinfo/tutor
>
>


from random import randrange
wins=0
win=[]
count=0
for count in range(5):
    win.append(randrange(55)+1)
powerball=randrange(42)+1
count=0
for count in range(146107962):
    numbers=[]
    count2=0
    for count2 in range(5):
        number=randrange(55)+1
        if number in win:
            numbers.append(number)
        else:
            print "lose"
            break
        numbers.sort()
        win.sort()
        ball=randrange(42)+1
        if ball == powerball:
            print "win"
            win=win+1
print
print
print win, powerball
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to