<div>Hello,</div>
<div> </div>
<div>I'm not so sure about your problem, but </div>
<div>probably this code can help....</div>
<div> </div>
<p> sumHead, sumTail = 0,0</p>
<p> listHeadTime = []<br> listTailTime = []<br> <br> for i in range(100):<br> time_start = time.clock()<br> coin = random.randint(0,1) # 0 head, 1 tail<br> time_stop = time.clock()<br> time_duration = time_stop - time_start
<br> <br> if coin == 0:<br> sumHead += 1<br> listHeadTime.append(time_duration)<br> else:<br> sumTail += 1<br> listTailTime.append(time_duration)</p>
<p> print sumHead, sumTail<br> print listHeadTime<br> print listTailTime<br></p>
<div><br> </div>
<div>Cheers,</div>
<div>pujo<br> </div>
<div><span class="gmail_quote">On 10/26/05, <b class="gmail_sendername">Danny Yoo</b> <<a href="mailto:dyoo@hkn.eecs.berkeley.edu">dyoo@hkn.eecs.berkeley.edu</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br><br>> > My goal, create a program that flips a coin 100 times, at the end it<br>> > says the number of times it flipped heads and flipped tails.
<br>><br>> Do you might if we simplify the problem slightly? Say that you're only<br>> flipping the coin two times. Can you write code to say how many times<br>> it flips heads and tails? Once you get that working, then modify that
<br>> program to do it for three coins, then four.<br><br>Duh: I forgot to add: can you try to do the above without loops? Since<br>there's so little coin flipping going on, the code to do this shouldn't be<br>too long to write, even without loops.
<br><br>(... although it will get longer for each additional coin we flip. When<br>we want to scale our solution to more coins, then that's where loops can<br>come into play.)<br><br>_______________________________________________
<br>Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>