[Tutor] New programmer, need some help getting started on my first project

Chris Delgado prowlerslim at yahoo.com
Fri May 19 03:26:03 CEST 2006


Bob et al, 

Ok guys, program is all fixed up and runs well. HEre is the final code. Thanks for the help and its on to the next prog.  Thanks for the patience and help!

Chris

# A program that simulates flipping a coin 100 times and the reports the number of heads and tails that were flipped#

import random

heads = 0
tails = 0
flips = 0

while flips < 100:

    coin = random.randrange(2)

    if coin == 0:
        heads += 1
    else:
        tails += 1

    flips += 1  

print "The coin was flipped 100 times and it was heads " +str(heads)+ " times and tails " + str(tails) + " times!"

raw_input("\n\nPress the Enter key to exit")


		
---------------------------------
Love cheap thrills? Enjoy PC-to-Phone  calls to 30+ countries for just 2¢/min with Yahoo! Messenger with Voice.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060518/7bf22832/attachment.htm 


More information about the Tutor mailing list