For each President, compute how many more days passed before their death in their year of death
Question:
For each President, compute how many more days passed before their death in their year of death than before their birth in their year of birth. For example, that number for George Washington is 295, and for John Adams it's -118. We'll call this number the "net additional life days."
In [ ]:
net_additional_life_days = death_days - birth_daysimport numpy as np from datascience import * detailed_ages.with_column("Net Additional Life Days", net_additional_life_days)
To get each President's actual age at death, we should subtract 1 from the longevity of Presidents whose net additional life days are negative. One way to do this is:
Divide each net additional life day amount by 366 to get a fraction of a year.
Round each fraction down to the nearest integer, using the function np.floor. (np.floor takes as its argument an array of numbers. It returns an array of those numbers rounded down to the nearest integer.)
Add the result to each President's longevity
Project Management The Managerial Process
ISBN: 9781260570434
8th Edition
Authors: Eric W Larson, Clifford F. Gray