[Tutor] (no subject)

bhaaluu bhaaluu at gmail.com
Wed Oct 1 22:45:58 CEST 2008

Correction of post typo follows.....

On Wed, Oct 1, 2008 at 8:57 AM, bhaaluu <bhaaluu at gmail.com> wrote:
> #Now, let's flip the coin (PROCESS).
> while count != 0:
>    #each time through the loop, flip will randomly choose a side of the coin
>    flip = random.choice(coin)
>    #if/else selection. There are only two choices.
>    if flip == "heads":
>        heads += 1
>    else:
>        tails += 1
>    #decrement the counter, or you'll be in an infinite loop
>    #it started at 100, so subtract one each iteration
>    count -= 1
> Not the indentation after the while loop line.
> That's a Python thing.

That should be "NOTE the indentation after the while loop".
Also note the indentation after the if and else lines. Python
uses indentation to define 'blocks' of code. Another little
detail that may escape one's notice is that the first line
of each block ends with a colon. A block is finished when
the indentation ends. Blocks of code may be nested
within each other, as long as they are properly indented.

> Since I've put so much time into this tutorial, I have a
> challenge for you: Write a program that rolls a pair of
> ten-sided dice, and tell me what the outcome of the roll is?
> How about the outcome of three rolls?

The programming challenge still stands! Kayla? (BTW, when
I say "tell me what the outcome is", I'm asking for your program
to produce some OUTPUT!)

Happy [Python] Programming!
b h a a l u u at g m a i l dot c o m
Kid on Bus: What are you gonna do today, Napoleon?
Napoleon Dynamite: Whatever I feel like I wanna do. Gosh!

More information about the Tutor mailing list