Gth of that array an integer question 4 the cell

This preview shows page 5 - 9 out of 23 pages.

gth of that array (an integer).Question 4.The cell below loads an array calledpresident_birth_years.The last ele-ment in that array is the most recent birth year of any deceased president. Assign that year tomost_recent_birth_year.5
In [16]:president_birth_years=Table.read_table("president_births.csv").column('Birth Year')most_recent_birth_year=president_birth_years[len(president_birth_years)-1]most_recent_birth_yearOut[16]:1917In [17]:_=ok.grade('q2_4')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Running tests---------------------------------------------------------------------Test summaryPassed: 1Failed: 0[ooooooooook] 100.0% passedQuestion 5.Finally, assignsum_of_birth_yearsto the sum of the first, tenth, and last birthyear inpresident_birth_yearsIn [18]:sum_of_birth_years=president_birth_years[len(president_birth_years)- 1]+presidentIn [19]:_=ok.grade('q2_5')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Running tests---------------------------------------------------------------------Test summaryPassed: 1Failed: 0[ooooooooook] 100.0% passed1.33. Basic Array ArithmeticQuestion 1.Multiply the numbers 42, 4224, 42422424, and -250 by 157. Assign each variable belowsuch thatfirst_productis assigned to the result of 42*157,second_productis assigned to theresult of 4224*157, and so on.For this question,don’tuse arrays.
6
6594 663168 6660320568 -39250In [21]:_=ok.grade('q3_1')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Running tests---------------------------------------------------------------------Test summaryPassed: 1Failed: 0[ooooooooook] 100.0% passedQuestion 2.Now, do the same calculation, but using an array callednumbersand only a singlemultiplication (*) operator. Store the 4 results in an array namedproducts.In [22]:numbers=make_array(42,4224,42422424,-250)products= 157 *numbersproductsOut[22]:array([6594,663168, 6660320568,-39250])In [23]:_=ok.grade('q3_2')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Running tests---------------------------------------------------------------------Test summaryPassed: 1Failed: 0[ooooooooook] 100.0% passedQuestion 3.Oops, we made a typo! Instead of 157, we wanted to multiply each number by1577. Compute the fixed products in the cell below using array arithmetic. Notice that your job isreally easy if you previously defined an array containing the 4 numbers.
7
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Running tests---------------------------------------------------------------------Test summaryPassed: 1Failed: 0[ooooooooook] 100.0% passedQuestion 4.We’ve loaded an array of temperatures in the next cell. Each number is the highesttemperature observed on a day at a climate observation station, mostly from the US. Since they’refrom the US government agencyNOAA, all the temperatures are in Fahrenheit. Convert themall to Celsius by first subtracting 32 from them, then multiplying the results by59.Make suretoROUNDthe final result after converting to Celsius to the nearest integer using thenp.roundfunction.
Running tests---------------------------------------------------------------------Test summaryPassed: 3Failed: 0[ooooooooook] 100.0% passedQuestion 5.The cell below loads all thelowesttemperatures from each day (in Fahrenheit).

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 23 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
World population

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture