6.00.2x-pset3.py
def reproduce(self, popDensity, activeDrugs):
        """
        Stochastically determines whether this virus particle reproduces at a
        time step. Called by the update() method in the TreatedPatient class.

        popDensity: the population density (a float), defined as the current
        virus population divided by the maximum population.

        activeDrugs: a list of the drug names acting on this virus particle
        (a list of strings).

        returns: a new instance of the ResistantVirus class representing the
        offspring of this virus particle. The child has the same
        maxBirthProb and clearProb values as this virus. Raises a
        NoChildException if this virus particle does not reproduce.
        """
        for drug in activeDrugs:
            if not self.isResistantTo(drug):
                raise NoChildException('NoChildException')
        inheritance = dict(self.getResistances())
        for trait in inheritance:
            if random.random() <= self.getMutProb():
                inheritance[trait] = not self.getResistances()[trait]
        if random.random() <= (self.maxBirthProb * (1 - popDensity)):
            # Line bellow broken to comply with pep8
            return ResistantVirus(self.maxBirthProb, self.clearProb,
                                  inheritance, self.getMutProb())
        else:
            raise NoChildException('NoChildException')

        Stochastically determines whether this virus particle reproduces at a
        time step. Called by the update() method in the TreatedPatient class.

        popDensity: the population density (a float), defined as the current
        virus population divided by the maximum population.

        activeDrugs: a list of the drug names acting on this virus particle
        (a list of strings).

        returns: a new instance of the ResistantVirus class representing the
        offspring of this virus particle. The child has the same
        maxBirthProb and clearProb values as this virus. Raises a
        NoChildException if this virus particle does not reproduce.
        
Stochastically determines whether this virus particle reproduces at a
time step. Called by the update() method in the TreatedPatient class.

the population density (a float), defined as the current
virus population divided by the maximum population.

a list of the drug names acting on this virus particle
(a list of strings).

a new instance of the ResistantVirus class representing the
offspring of this virus particle. The child has the same
maxBirthProb and clearProb values as this virus. Raises a
NoChildException if this virus particle does not reproduce.
Stochastically determines whether this virus particle reproduces at a time step . Called by the update () method in the TreatedPatient class . the population density ( a float ) defined as the current virus population divided by the maximum population . a list of the drug names acting on this virus particle ( a list of strings ) . a new instance of the ResistantVirus class representing the offspring of this virus particle . The child has the same maxBirthProb and clearProb values as this virus . Raises a NoChildException if this virus particle does not reproduce .
def reproduce(self, popDensity, activeDrugs):
        for drug in activeDrugs:
            if not self.isResistantTo(drug):
                raise NoChildException('NoChildException')
        inheritance = dict(self.getResistances())
        for trait in inheritance:
            if random.random() <= self.getMutProb():
                inheritance[trait] = not self.getResistances()[trait]
        if random.random() <= (self.maxBirthProb * (1 - popDensity)):
            return ResistantVirus(self.maxBirthProb, self.clearProb,
                                  inheritance, self.getMutProb())
        else:
            raise NoChildException('NoChildException')
def reproduce ( self , popDensity , activeDrugs ) : for drug in activeDrugs : if not self . isResistantTo ( drug ) : raise NoChildException ( 'NoChildException' ) inheritance = dict ( self . getResistances ( ) ) for trait in inheritance : if random . random ( ) <= self . getMutProb ( ) : inheritance [ trait ] = not self . getResistances ( ) [ trait ] if random . random ( ) <= ( self . maxBirthProb * ( 1 - popDensity ) ) : return ResistantVirus ( self . maxBirthProb , self . clearProb , inheritance , self . getMutProb ( ) ) else : raise NoChildException ( 'NoChildException' )
Stochastically determines whether this virus particle reproduces at a
time step.
Stochastically determines whether this virus particle reproduces at a time step .
"""
        Stochastically determines whether this virus particle reproduces at a
        time step. Called by the update() method in the TreatedPatient class.

        popDensity: the population density (a float), defined as the current
        virus population divided by the maximum population.

        activeDrugs: a list of the drug names acting on this virus particle
        (a list of strings).

        returns: a new instance of the ResistantVirus class representing the
        offspring of this virus particle. The child has the same
        maxBirthProb and clearProb values as this virus. Raises a
        NoChildException if this virus particle does not reproduce.
        """ # Line bellow broken to comply with pep8
self
popDensity
activeDrugs