Thankyou..!!!<br><br><br>Regards,<br>Nithya<br><br><div class="gmail_quote">On Tue, Nov 16, 2010 at 1:51 PM, Luke Pettit <span dir="ltr"><<a href="mailto:petluke@gmail.com">petluke@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Arrr thats better <span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(121, 6, 25); font-weight: bold; white-space: nowrap;">Nithya</span><font face="arial, sans-serif"><span style="border-collapse: collapse; white-space: nowrap;"> it works fine now. I had it working fine before it was just coming up with that strange result of 73 and 100 </span></font><div>
<font face="arial, sans-serif"><span style="border-collapse: collapse; white-space: nowrap;">when I copied the code into wing to check it out in order to understand it. Wing picked up the spacing and I had already corrected</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse: collapse; white-space: nowrap;">that Dave as I was simply looking at Nithya code.</span></font><div><div></div><div class="h5"><br>
<br><div class="gmail_quote">On 16 November 2010 19:10, Nithya Nisha <span dir="ltr"><<a href="mailto:nithyakarpagam@gmail.com" target="_blank">nithyakarpagam@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi there,<br><br>This is the Code. Please check it.It is working fine.<br><br>>>>import random<br>
>>>headsCount = 0<br>>>>tailsCount = 0<br>>>>count = 1<br>>>><br>>>>while count <= 100:<br>>>> coin = random.randrange(2)<br>>>> if coin == 0:<br>
>>> headsCount += 1<br>>>> else:<br>>>> tailsCount += 1<br>>>> count += 1<br>>>><br>>>>print "The number of heads was", headsCount<br>
>>>print "The number of tails was", tailsCount<br>>>><br>>>>raw_input("\n\nPress the enter key to exit.")<br><br>________________________________________________________________________________________________________________<u><b><br>
Your Description </b></u>:<br><br><div class="gmail_quote">On Tue, Nov 16, 2010 at 1:25 PM, Dave Angel <span dir="ltr"><<a href="mailto:davea@ieee.org" target="_blank">davea@ieee.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
When I run this code (I'm also a noob) I get this result:-<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
[evaluate lines 1-22 from untitled-1.py]<br>
</blockquote></blockquote></blockquote>
The number of heads was 73<br>
The number of tails was 100<br>
<br>
Press the enter key to exit.<br>
<br>
# Surely, if flipping a single coin 100 times your total number of heads and<br>
tails should add up to 100<br>
# not 173 or am I missing the point?<br>
<br>
<br>
</blockquote></div>
No, you're missing an indentation. If you check the code you're running, I think you'll find that you didn't unindent the line incrementing count.<br>
<br>
Of course, it's less error prone to simply use<br>
for count in xrange(100):<br>
<br>
instead of while count < 100:<br>
<br>
and you wouldn't need to increment count.<br>
<br>
DaveA<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>With Regards,<br>Nithya S<br><br>
</blockquote></div><br><br clear="all"><br></div></div>-- <br>Luke Pettit<br>
</div>
</blockquote></div><br><br clear="all"><br><br>