[Tutor] Need help solving this problem

Alan Gauld alan.gauld at btinternet.com
Wed Jun 10 23:26:35 CEST 2009

"Raj Medhekar" <cosmicsand27 at yahoo.com> wrote

> Write a program that flips a coin 100 times and the tells you the number 
> of heads and tails.
> 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.

You also need to understand the concept of variables as data stores.
And you will probably need to use a mechanism to generate random
values. The random module will help or you can simply read the time
and strip off the last two digits - that will be good enough for your

Otherwise take a look at my tutorial for the various topics
Raw Materials - variables and data
File handling - for a very brief intro to reading the time


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list