Hello,
 
I'm not so sure about your problem, but
probably this code can help....
 

    sumHead, sumTail = 0,0

    listHeadTime = []
    listTailTime = []
   
    for i in range(100):
        time_start = time.clock()
        coin = random.randint(0,1) # 0 head, 1 tail
        time_stop = time.clock()
        time_duration = time_stop - time_start
       
        if coin == 0:
            sumHead += 1
            listHeadTime.append(time_duration)
        else:
            sumTail += 1
            listTailTime.append(time_duration)

    print sumHead, sumTail
    print listHeadTime
    print listTailTime


 
Cheers,
pujo
 
On 10/26/05, Danny Yoo <[EMAIL PROTECTED]> wrote:


> >  My goal, create a program that flips a coin 100 times, at the end it
> > says the number of times it flipped heads and flipped tails.
>
> Do you might if we simplify the problem slightly?  Say that you're only
> flipping the coin two times.  Can you write code to say how many times
> it flips heads and tails?  Once you get that working, then modify that
> program to do it for three coins, then four.

Duh: I forgot to add: can you try to do the above without loops?  Since
there's so little coin flipping going on, the code to do this shouldn't be
too long to write, even without loops.

(... although it will get longer for each additional coin we flip.  When
we want to scale our solution to more coins, then that's where loops can
come into play.)

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to