[Tutor] powerball
bob gailer
bgailer at gmail.com
Wed Jun 11 20:46:57 CEST 2008
max baseman wrote:
> as a fun little project i scripted a powerball program. it seems to
> have a bug in it that i cant find.
To echo Kent: tell us the expected outcome and why you think there is a
bug.
Also please add a comment explaining the "magic" number 146107962.
Also add a comment about "powerball". I had to Google it to find out
what it is!
That aside, the program will run forever (until interrupted).
It is common practice to walk thru the program yourself to test it. I
suggest you do this. Write down the values of variables and note when
they change. Perhaps there are some that should change and are not
changing.
>
> 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
>
--
Bob Gailer
919-636-4239 Chapel Hill, NC
More information about the Tutor
mailing list