print
"This is a coin flip game"
print
"\n100 flips will be made and it will show the amount of times heads or
tails came up"
import
random
#assigning variables to track the amount of times heads or tails comes
up
heads=0
tails=1
flip=100
while flip < 100:
flip -= 1
random.randrange(2)
if flip < 100:
break
print
"\nThe amount of times tails came up was" , tails , "The amount of
times heads came up was" , heads
raw_input()
At 10:53 PM 10/25/2005, Nick Eberle wrote:
Content-class:
urn:content-classes:message
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C5D9F1.A836CF4F"
Sorry for potential double post, error with first
send
----------------------------------------------------------------------
Hello all,
I had a new question about python. I am
pretty much in tutorial learning stages, but attempting to create
sample programs not in my book to learn how to construct scripts.
I understand the format of while loops,
but is it possible to use the random.randrange function in them?
My goal, create a program that flips a
coin 100 times, at the end it says the number of times it flipped heads
and flipped tails.
My dilemia, how do I get this to work
with a while loop? I tried intially assigning
heads=0
tails=1
then I figured I could just do a while
loop and then use the random function each time. At the end it could
count the number of times the random generated a 0 or a 1.
However I can't seem to construct it in
a way that makes or works.
Show us your code, as flawed as it might be. Then we can advise you.