<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<font class="Apple-style-span" face="Tahoma" size="4"><span class="Apple-style-span" style="font-size: 10pt;">Greetings,</span></font><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div style="font-family: Tahoma; font-size: 10pt; ">As a thread starter, I thought I should write the rewritten code I got that others helped me get to, since this thread is still going on.</div><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"># Coin Flips</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"># The program flips a coin 100 times and then</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"># tells you the number of heads and tails</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">import random</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">print "\a"</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">print "\tWelcome to 'Coin Flipper!'"</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">print "\nI will flip a coin 100 times and then tell you"</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">print "the number of heads and tails!\n"</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"># set the coin</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">headsCount = 0</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">tailsCount = 0</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">count = 1</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">while count &lt;= 100:</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp;coin = random.randrange(2)</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp;if coin == 0:</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;headsCount += 1</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp;else:</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;tailsCount += 1</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp;count += 1</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp;</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">print "The number of heads was", headsCount</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">print "The number of tails was", tailsCount</span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Tahoma" size="3"><span class="Apple-style-span" style="font-size: 13px;">raw_input("\n\nPress the enter key to exit.")</span></font></div></div><div style="font-family: Tahoma; font-size: 10pt; "><br></div>                                               </body>
</html>