<div>Hello,</div>
<div>&nbsp;</div>
<div>I'm not so sure about your problem, but </div>
<div>probably this code can help....</div>
<div>&nbsp;</div>
<p>&nbsp;&nbsp;&nbsp; sumHead, sumTail = 0,0</p>
<p>&nbsp;&nbsp;&nbsp; listHeadTime = []<br>&nbsp;&nbsp;&nbsp; listTailTime = []<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; for i in range(100):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time_start = time.clock()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; coin = random.randint(0,1) # 0 head, 1 tail<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time_stop = time.clock()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time_duration = time_stop - time_start
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if coin == 0:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sumHead += 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; listHeadTime.append(time_duration)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sumTail += 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; listTailTime.append(time_duration)</p>
<p>&nbsp;&nbsp;&nbsp; print sumHead, sumTail<br>&nbsp;&nbsp;&nbsp; print listHeadTime<br>&nbsp;&nbsp;&nbsp; print listTailTime<br></p>
<div><br>&nbsp;</div>
<div>Cheers,</div>
<div>pujo<br>&nbsp;</div>
<div><span class="gmail_quote">On 10/26/05, <b class="gmail_sendername">Danny Yoo</b> &lt;<a href="mailto:dyoo@hkn.eecs.berkeley.edu">dyoo@hkn.eecs.berkeley.edu</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br><br>&gt; &gt;&nbsp;&nbsp;My goal, create a program that flips a coin 100 times, at the end it<br>&gt; &gt; says the number of times it flipped heads and flipped tails.
<br>&gt;<br>&gt; Do you might if we simplify the problem slightly?&nbsp;&nbsp;Say that you're only<br>&gt; flipping the coin two times.&nbsp;&nbsp;Can you write code to say how many times<br>&gt; it flips heads and tails?&nbsp;&nbsp;Once you get that working, then modify that
<br>&gt; 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?&nbsp;&nbsp;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.&nbsp;&nbsp;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&nbsp;&nbsp;-&nbsp;&nbsp;<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>