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
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
Step by Step Solution
3.47 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
This code snippet computes the net additional life days for each President by subtracting the num...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started