I&#39;ve recently been going through &quot;Python Programming, for the Absolute Beginner&quot;  Second Edition, By Michael Dawson<br><br>I&#39;m running python 2.5.4 on a windows xp home machine. <br><br>So my question boils down to this:<br>
<br>At the end of one of his chapters there is a challenge to write a program that flips a &quot;coin&quot; 100 times then outputs the number of heads or tails it hit.<br><br>I wrote this:<br><br>import random<br>flip = 0<br>
head = 0<br>tails = 0<br><br>while flip != 100:<br>????flip += 1<br>????coin = random.randrange(2)<br>????if coin == 0<br>????????head += 1<br>????elif coin == 1<br>????????tails += 1<br><br>print head, tails<br><br>raw_input(&quot;\n&lt;return&gt;&quot;)<br>
<br><br>I honestly don&#39;t know how code works and would appreciate someone explaining it to me?<br><br>Using logic, I shouldn&#39;t be able to write the program due to my limited skills so  i  don&#39;t know how to explain HOW i wrote it because it just sort of happened. I was sitting home one night and it just came out itself.  I know that&#39;s not much of an explanation but there it is. <br>
<br>Thanks in advance,<br>Slacker<br>