1. If you have error please show us your error message.
2. When you code python be aware of indention, be persistent for example use tab space 4.
3. import should be on the top of your code.
4. to choose random between integer 1 or 0 use randint(0,1)
5. your last code use Print it should be print (small letter please).
Cheers,
pujo
On 10/31/05,
Zameer Manji <[EMAIL PROTECTED]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
I'm new to programming and python. I've have recently been experimenting
with while/if/elif/else loops and I've created a simple number guessing
game. Now I want to create a coin tossing game, but I don't know how to
structure it in python. The code I already have (but it's not working)
is below.
#Coin Toss Game
print "This game will simulate 100 coin tosses and then tell you the
number of head's and tails"
import random
tosses = 0
heads = 0
tails = 0
while tosses = 100<0:
coin = randrange(1)
tosses +=1
if coin == 0:
heads +=1
print "Heads"
else:
tails +=1
Print "Tails"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
iQEVAwUBQ2accw759sZQuQ1BAQqoyQgAsmVhRidMC1/WpQms6fChX+z62DWSpmRW
qiY9F7bZAYZusyNsHHDUpuTAYdI0LXxgLVmYBKDz3tKhVCbEZTn9FUwgw5A2thYy
I5o82tWXZnIpgmFIN2AysAj2dCI4mSfi/IJjE5JvG+IFELWigMb9Pf6tap4HiB71
IBayql8MN1XrA2zv8fXQs35zVwxnBUSvAHZuUBLi4hDcPxY/d71X/JHqfqpf3svS
ClzUlYqLhXld+39/aiRFKOXHyVCnfsEUcAXB45r110Q3K+7KegwgX4Js8qL5dA66
d74HlLMb6Cp6G5AlNdQoKDin8jlMloxeQpb60hS+HmnBwkEFukyNHA==
=QMuB
-----END PGP SIGNATURE-----
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
