Question 1 multiply the numbers 42 4224 42422424 and

This preview shows page 6 - 11 out of 20 pages.

Question 1. Multiply the numbers 42, 4224, 42422424, and -250 by 157. For this question, don't use arrays.In [43]:first_product = 42*157second_product = 4224*157third_product = 42422424*157fourth_product = (-250)*157
print(first_product, second_product, third_product, fourth_product)6594 663168 6660320568 -39250In [44]:_ = 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 [56]:numbers = make_array(42, 4224, 42422424, -250)products = numbers*157productsOut[56]:array([6594,663168, 6660320568,-39250])In [57]:_ = 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 by 1577. Computethe fixed products in the cell below using array arithmetic. Notice that your job is really easy if youpreviously defined an array containing the 4 numbers.In [58]:fixed_products = numbers*1577fixed_productsOut[58]:array([66234,6661248, 66900162648,-394250])
In [59]:_ = ok.grade('q3_3')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~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're from theUS government agencyNOAA, all the temperatures are in Fahrenheit. Convert them all to Celsius by firstsubtracting 32 from them, then multiplying the results by5959. Make sure to ROUND each result to thenearest integer using thenp.roundfunction.In [66]:max_temperatures = Table.read_table("temperatures.csv").column("Daily Max Temperature")celsius_max_temperatures = np.round((max_temperatures - 32)*(5/9))celsius_max_temperaturesOut[66]:array([-4., 31., 32., ..., 17., 23., 16.])In [67]:_ = ok.grade('q3_4')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Running tests---------------------------------------------------------------------Test summaryPassed: 3Failed: 0[ooooooooook] 100.0% passedQuestion 5. The cell below loads all thelowesttemperatures from each day (in Fahrenheit). Compute thesize of the daily temperature range for each day. That is, compute the difference between each dailymaximum temperature and the corresponding daily minimum temperature. Give your answer in Celsius!Make sure NOT to round your answer for this question!In [74]:min_temperatures = Table.read_table("temperatures.csv").column("Daily Min Temperature")
celsius_temperature_ranges = ((max_temperatures - 32)*(5/9)) - ((min_temperatures - 32)*(5/9))celsius_temperature_rangesOut[74]:array([ 6.66666667, 10., 12.22222222, ..., 17.22222222,11.66666667, 11.11111111])In [75]:_ = ok.grade('q3_5')~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Running tests---------------------------------------------------------------------Test summaryPassed: 1Failed: 0[ooooooooook] 100.0% passed4. World PopulationThe cell below loads a table of estimates of the world population for different years, starting in 1950. Theestimates come from theUS Census Bureau website.In [76]:world = Table.read_table("world_population.csv").select('Year', 'Population')world.show(4)Year Population1950 25576286541951 25949398771952 26367723061953 2682053389... (62 rows omitted)The namepopulationis assigned to an array of population estimates.In [79]:population = world.column(1)populationOut[79]:array([2557628654, 2594939877, 2636772306, 2682053389, 2730228104,2782098943, 2835299673, 2891349717, 2948137248, 3000716593,3043001508, 3083966929, 3140093217, 3209827882, 3281201306,
3350425793, 3420677923, 3490333715, 3562313822, 3637159050,3712697742, 3790326948, 3866568653, 3942096442, 4016608813,4089083233, 4160185010, 4232084578, 4304105753, 4379013942,4451362735, 4534410125, 4614566561, 4695736743, 4774569391,4856462699, 4940571232, 5027200492, 5114557167, 5201440110,5288955934, 5371585922, 5456136278, 5538268316, 5618682132,5699202985, 5779440593, 5857972543, 5935213248, 6012074922,6088571383, 6165219247, 6242016348, 6318590956, 6395699509,6473044732, 6551263534, 6629913759, 6709049780, 6788214394,6866332358, 6944055583, 7022349283, 7101027895, 7178722893,7256490011])In this question, you will apply some built-in Numpy functions to this array.The difference functionnp.diff

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 20 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