sklei2 / DeathClock

0 stars 0 forks source link

[SPIKE] Determine Death Algorithm #23

Open sklei2 opened 7 years ago

sklei2 commented 7 years ago

With all of this information at our disposal, we need to make use of it.

mll8657 commented 6 years ago

success criteria: Add an example of the algorithm to the card

mll8657 commented 6 years ago

""" My example lifespan calculation algorithm """ avg_lifespan = 78 class CauseOfDeath: """ We need the number of people killed per year (a fixed number) We also need the number of years your risk factors for each cause of death will take off your life (I'm assuming that data will come from the form and our death poker) """ def init(self, name, dead_per_year, years_off_life): self.name = name self.weight = dead_per_year self.years_off_life = years_off_life

x = CauseOfDeath("cancer", 500, 25) y = CauseOfDeath("tripping on shoelaces", 15, 55) causes_of_death = [x, y]

def algorithm(causes): top = 0 bottom = 0 for cause in causes:

make a weighted average

    top += cause.weight * cause.years_off_life
    bottom += cause.weight
weighted_average = top/bottom
your_lifespan = avg_lifespan - weighted_average
print(your_lifespan)
sklei2 commented 6 years ago

That seems fine by me!!!!