"Colleen Glaeser" <songbird42...@gmail.com> wrote

First, write a function that simulates flipping a coin. This function needs no parameters. When called, it should return either “HEADS” or “TAILS”.
Those are strings.   That’s *return*, not print.

OK, You've done this

When that function is working, write another function to exercise it.

And you have almost done this

function should have one parameter, a positive number. This function will call the previous function that number of times, and count the number of heads. When finished, it should *return* (not print) the number of heads.

But not quite...

def multicoinToss(tosses):
    for i in range(tosses):

So far so good

       print (coinToss())

But instead of printing you want to count heads
Do you know how to test if the result of your function is "HEADS"?
Do you know how to increment a counter - ie add one to it?
Do you know how to return that value from your function at
the end of the for loop?

You should do, because you have done something very
similar to 1 and 3 in  your coinToss function.

Can anybody help me figure out how to do it?

Because its homework we won;t give you the answer just
some hints. Have another go and post the result if it doesn't
work.


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to