[Tutor] coin toss program without using the for/range loop
David
dseto200 at pacbell.net
Thu Jan 4 23:08:29 CET 2007
How to write the coin toss program without using the for/range loop program.
Program flips a coin 100 times and then tells you the number of heads and
tails.
I can only solve it using the for/range loop
Import random
Heads=0
For 1 in range (100):
Heads+=random.randrange(2)
print "Hit heads"+" "+str(heads)+" "+"times"+" " + "hit tails" + "
"+str(100-heads)+" " + "times"
I don't see how you solve this program just using the while loop program and
if/else statement.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070104/8ca7ecfd/attachment.html
More information about the Tutor
mailing list