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

Chris Delgado prowlerslim at yahoo.com
Fri May 19 01:19:49 CEST 2006


Kent, 

Thanks once again.

"I wonder if maybe you need to write some code? You talk about *reading* 
but you haven't mentioned *writing*. You can't learn to program without 
writing programs - that would be like learning to write a foreign 
language by reading books in the language - it helps but it won't get 
you there!

So if you have just been reading, I suggest you try writing a few small 
programs as warmups."

I think you are right on the money here. I need to write some more simple stuff. I did work through the books but I wrote very little on my own, just sort of followed along and said "Oh that makes sense". So I decided to go through the practice exercises in the book and then post here with any problems. 

SO here is my first stab and I keep getting a syntax error in my first if statement. The = sign is highlighted and I cant figure out what is wrong. Im almost embarassed to mail this. 
# 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

if flips <= 100:

    coin = random.randrange(2)

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

    flips +=1

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

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

THanks, 
Chris

 



		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060518/403c5074/attachment.htm 


More information about the Tutor mailing list