Open sklei2 opened 7 years ago
success criteria: Add an example of the algorithm to the card
""" 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:
top += cause.weight * cause.years_off_life
bottom += cause.weight
weighted_average = top/bottom
your_lifespan = avg_lifespan - weighted_average
print(your_lifespan)
That seems fine by me!!!!
With all of this information at our disposal, we need to make use of it.