<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.26.0">
</HEAD>
<BODY>
What you are looking at is a simulation whereby a coin having 2 outcomes (heads or tails) is flipped exactly 100 times. You need to tell how many times the coin falls heads up and how many times the coin falls tails up. <BR>
<BR>
First become familiar with the random module. Assign a value of 1 for heads and a value of 2 for tails. Then you are going to use a structure of the random module which will return only two possible outcomes. Either a one or a two. You are going to loop (look at range(1,101) or range(0,100). (Side question; why 101 or 0 to 100?; look closely at the meaning of the range arguments). Simply count the number of ones and the number of two's in the 100 flips then print the results. <BR>
<BR>
Good luck.<BR>
<BR>
Robert<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<BR>
</TD>
</TR>
</TABLE>
<BR>
On Wed, 2009-06-10 at 13:08 -0700, Raj Medhekar wrote:
<BLOCKQUOTE TYPE=CITE>
    I have been teaching myself Python using a book. The chapter I am on currently, covers branching, while loops and program planning. I am stuck on on of the challenges at the end of this chapter, and I was hoping to get some help with this. Here it is:<BR>
    <BR>
    Write a program that flips a coin 100 times and the tells you the number of heads and tails.<BR>
    <BR>
    I have tried to think about several ways to go about doing this but I have hit a wall. Even though I understand the general concept of branching and looping, I have been having trouble writing a program with these.&nbsp; I look forward to your reply that will help me understand these structures better.<BR>
    <BR>
    Sincerely,<BR>
    Raj<BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
<PRE>
_______________________________________________
Tutor maillist  -  <A HREF="mailto:Tutor@python.org">Tutor@python.org</A>
<A HREF="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</A>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>