Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python 3+, U.S. population data from 1950 to 2020 is provided in US_population.txt . United Nations projections are also included through the year 2100.

In Python 3+, U.S. population data from 1950 to 2020 is provided in US_population.txt. United Nations projections are also included through the year 2100.

You can view the file by any text editor. There are two columns in the file separated by a comma: the first column corresponds to the year and the second corresponds to the population.

  1. Create a numpy array with the population data.

    Hint: you may need split() function.

  2. Calculate the annual growth rate of the population based on the method you used in Q2(2). Do NOT use a for/while loop.

    Hint: If the population of year 2020 is a and the population of year 2021 is b, then the annual growth rate of 2021 is (b-a)/a.

    1. Randomly generate a numpy array with 1000 numbers in the shape of (10000,). The numbers should be in the range of 1 and 50 inclusive. Then,

      1. print the first 10 numbers, the last 10 numbers and the variance.
      2. calculate the difference of every two adjacent numbers in the array. For example, if the original array is [2,4,-1], then the array of difference should be [2, -5] because 4-2=2 and -1-4=-5. You should NOT use a for/while loop.
      3. calculate the sum of the difference array. Can you get this result without calculation?
      4. sort the original array.
  3. print the first 10 numbers, the last 10 numbers and the variance of the sorted array. Is the variance changed?
  4. Plot the population and annual growth rate as PT5_1.jpg and PT5_2.jpg. Use solid line for historical data (1950 through 2020) and dashed line for U.N. projections data (2020 through 2100).

PT5_1.jpg:

image text in transcribed

PT5_2.jpg:

image text in transcribed

From US_population.txt:

date, Population 1950-12-31,158804395 1951-12-31,160872266 1952-12-31,163266028 1953-12-31,165910003 1954-12-31,168736387 1955-12-31,171685336 1956-12-31,174705003 1957-12-31,177751483 1958-12-31,180788392 1959-12-31,183786252 1960-12-31,186720571 1961-12-31,189569843 1962-12-31,192313746 1963-12-31,194932403 1964-12-31,197408505 1965-12-31,199733676 1966-12-31,201895760 1967-12-31,203905080 1968-12-31,205805754 1969-12-31,207659263 1970-12-31,209513341 1971-12-31,211384068 1972-12-31,213269802 1973-12-31,215178797 1974-12-31,217114909 1975-12-31,219081251 1976-12-31,221086429 1977-12-31,223135663 1978-12-31,225223303 1979-12-31,227339318 1980-12-31,229476354 1981-12-31,231636058 1982-12-31,233821844 1983-12-31,236030238 1984-12-31,238256844 1985-12-31,240499825 1986-12-31,242763148 1987-12-31,245052789 1988-12-31,247372264 1989-12-31,249725805 1990-12-31,252120309 1991-12-31,254539370 1992-12-31,256990613 1993-12-31,259532129 1994-12-31,262241196 1995-12-31,265163745 1996-12-31,268335003 1997-12-31,271713635 1998-12-31,275175301 1999-12-31,278548150 2000-12-31,281710909 2001-12-31,284607993 2002-12-31,287279318 2003-12-31,289815562 2004-12-31,292354658 2005-12-31,294993511 2006-12-31,297758969 2007-12-31,300608429 2008-12-31,303486012 2009-12-31,306307567 2010-12-31,309011475 2011-12-31,311584047 2012-12-31,314043885 2013-12-31,316400538 2014-12-31,318673411 2015-12-31,320878310 2016-12-31,323015995 2017-12-31,325084756 2018-12-31,327096265 2019-12-31,329064917 2020-12-31,331002651 2021-12-31,332915073 2022-12-31,334805269 2023-12-31,336679228 2024-12-31,338542561 2025-12-31,340399601 2026-12-31,342251981 2027-12-31,344100706 2028-12-31,345947845 2029-12-31,347795038 1930-12-31,349641876 1931-12-31,351490184 1932-12-31,353335452 1933-12-31,355162916 1934-12-31,356952973 1935-12-31,358690999 1936-12-31,360371861 1937-12-31,361997623 1938-12-31,363570010 1939-12-31,365093533 1940-12-31,366572154 1941-12-31,368006423 1942-12-31,369396553 1943-12-31,370746303 1944-12-31,372060392 1945-12-31,373343348 1946-12-31,374598063 1947-12-31,375827634 1948-12-31,377037237 1949-12-31,378232675 1950-12-31,379419102 1951-12-31,380599427 1952-12-31,381776449 1953-12-31,382954886 1954-12-31,384139750 1955-12-31,385334861 1956-12-31,386542306 1957-12-31,387762561 1958-12-31,388995481 1959-12-31,390240014 1960-12-31,391494896 1961-12-31,392759632 1962-12-31,394033207 1963-12-31,395312812 1964-12-31,396594900 1965-12-31,397876093 1966-12-31,399154712 1967-12-31,400428621 1968-12-31,401693245 1969-12-31,402943276 1970-12-31,404174399 1971-12-31,405384568 1972-12-31,406572835 1973-12-31,407737648 1974-12-31,408877809 1975-12-31,409992632 1976-12-31,411081498 1977-12-31,412144637 1978-12-31,413183530 1979-12-31,414200417 1980-12-31,415197399 1981-12-31,416175706 1982-12-31,417136523 1983-12-31,418082081 1984-12-31,419014901 1985-12-31,419937440 1986-12-31,420851149 1987-12-31,421757887 1988-12-31,422660912 1989-12-31,423563930 1990-12-31,424469916 1991-12-31,425380718 1992-12-31,426297198 1993-12-31,427219557 1994-12-31,428147714 1995-12-31,429081658 1996-12-31,430021582 1997-12-31,430967919 1998-12-31,431921386 1999-12-31,432882959 2000-12-31,433853891

le8 US Population Chart 4.0 3.5 Popolation 3.0 2.5 2.0 15 1960 1980 2000 2040 2060 2080 2100 2020 Year US Population Chart 18 16 14 12 Annual % Change 10 0.8 0.6 0.4 0.2 1960 1980 2000 2040 2060 2080 2100 2020 Year le8 US Population Chart 4.0 3.5 Popolation 3.0 2.5 2.0 15 1960 1980 2000 2040 2060 2080 2100 2020 Year US Population Chart 18 16 14 12 Annual % Change 10 0.8 0.6 0.4 0.2 1960 1980 2000 2040 2060 2080 2100 2020 Year

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Accounting For Executives And MBAs

Authors: Ferris & Wallace

2nd Edition

1934319627, 978-1934319628

More Books

Students also viewed these Accounting questions