> I wrote this code but I know its wrong. Although it works properly:
> flips=0
> h='heads'
> t='tails'
> while True:
> flips+=1
> if flips>100:
> break
> if True:
> print(flips,'=',h or t)
> But
it prints every number with the string 'heads'. I'm really blank at
this. It may have
> something to do with the 'random' module.
Keep in mind, you never import the random module in this code,
so the problem could have nothing to do with that module. When
you use a module in Python, you import it, and there will be a line
at the top like this:
import random
Read up on importing modules; they are very important (pardon the
pun) in Python. The random module, like most of the modules, has
lots of functions in it for cases where randomization is needed. You
can read up on it: http://docs.python.org/library/random.html
I also really like Effbot's guide to the modules; for example, for random:
http://effbot.org/librarybook/random.htm
Che
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/171222986/direct/01/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor