[Tutor] Coin toss program
Neil Schemenauer
nas-pytut at python.ca
Wed Nov 5 13:02:54 EST 2003
On Wed, Oct 29, 2003 at 01:02:17PM -0500, LONG, SPENCER wrote:
> I'm having difficulty writing code for the following end of chapter
> exercise:
>
> "Write a program that flips a coin 100 times and then tells you the number
> of heads and tails."
>
> Can anyone forward to this Newbie the code for how this is accomplished? So
> far I have code that flips the coin once (using a random number generator),
> which results in either a heads or tails. But again, it's a single flip of
> the coin.
Could you post the code you have? To do something 100 times I would
use a for loop, eg.:
for i in range(100):
print "Hello world"
HTH,
Neil
More information about the Tutor
mailing list