Question
country = [HUN,MAC,PHL,SVK,USA] is the list of country codes LE_1960 = [65.57, 32.33, 70.82, 32.36, 50.55] is the list of the Life Expectancy at Birth
country = ["HUN","MAC","PHL","SVK","USA"] is the list of country codes
LE_1960 = [65.57, 32.33, 70.82, 32.36, 50.55] is the list of the Life Expectancy at Birth of each countries in 1960.
LE_2013 = [75.33, 77.54, 82.28, 80.89, 69.98] is the list of the Life Expectancy at Birth of each countries in 2013
Calculate the percentage improvement in Life Expectancy between 1960 and 2013 for each country and store it as a new list.
Output those countries that achieved 100% or more improvement in LE.
Show two columns along with headings.
Country Code %increase in LE
*** ***
My answer is added below, but it doesn't work out.
increase = []
alist = []
print("-"*24)
print( "%-12s%12s" % ("Country Code","%increase in LE"))
print("-"*24)
# Calculate the percentage improvement in Life Expectancy between 1960 and 2013 for each country and store it in a new list.
for i in range(len(country)):
increase = ((LE_2013[i]-LE_1960[i]) / LE_1960[i])
alist.append(increase)
# Remove countries whose Life Expectancy is less than 100% and store it in a new list.
for k in range(len(alist)):
if alist[k] < 1:
country_result = country.remove(country[k])
LE_result = alist.remove(k)
print( "%-12s%12.2f" % (country_result, LE_result))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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