Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python use np.round Here is one simple question we might ask about world population: How big was the population in each year, rounded to the

python use np.roundimage text in transcribed

Here is one simple question we might ask about world population: How big was the population in each year, rounded to the nearest million? Rounding is often used with large numbers when we don't need as much precision in our numbers. One example of this is when we present data in tables and visualizations. We could try to answer our question using the round function that is built into Python and the item method you just saw. Note: the round function takes in two arguments: the number to be rounded, and the number of decimal places to round to. The second argument can be thought of as how many steps right or left you move from the decimal point. Negative numbers tell us to move left, and positive numbers tell us to move right. So, if we heve round ( 1234.5,2), it means that we should move two places left, and then make all numbers to the right of this place zeroes. This would output the number 1200.0. On the other hand, if we have round (6.789,1), we should move one place right, and then make all numbers to the right of this place zeroes. This would output the number 6.8. population_1950_magnitude = round ( population_amounts.item (0),6) population_1951_magnitude = round ( population_amounts.item (1),6) population_1952_magnitude = round ( population_amounts.item (2),6) population_1953_magnitude = round ( population_amounts.item (3),6) But this is tedious and doesn't really take advantage of the fact that we are using a computer. Instead, NumPy provides its own version of round that rounds each element of an array. It takes in two arguments: a single array of numbers, and the number of decimal places to round to. It returns an array of the same length, where the first element of the result is the first element of the argument rounded, Question 2.3.1. Use np. round to compute the world population in every year, rounded to the nearest million (6 zeroes). Give the result (an array of 66 numbers) the name population_rounded. Your code should be very short. population_rounded =

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_2

Step: 3

blur-text-image_3

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

Students also viewed these Databases questions