[Tutor] Random Variable at root

halamillo halamillo at wsu.edu
Wed Oct 4 02:16:25 CEST 2006


Hello,
  I'm a really-green-to-python Biology Grad Student. I;m starting  
this code so I can assign either a 0 or a 1 at a root node that I  
will later evolve throughout a tree, but for some reason it is not  
printing the rootState value.  I know its probably a really stupid  
mistake, but I can't seem to work it out. Can anyone give me insight  
why? Thanks.

import random
from random import random as rnd
from math import exp


class Root:
     """Single Node in a Tree"""

     def __init__( self, rootState ):


         self._rootState = rootState

         # random choice for root state from a list
         for i in range(1):
             rootState = random.choice([0, 1])


     def __str__( self ):
         """Root string representation"""


         return str( self._rootState )
print "The character state at the root is %0.f" % rootState


Hugo Alamillo
Biological Sciences
265 Eastlick
PO Box 644236
Washington State University
Pullman, WA 99164





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061003/7c6b977c/attachment.html 


More information about the Tutor mailing list