1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LenaWriter [7]
3 years ago
10

Write a Python program that reads the CSV file, compares the population estimates of every row for 2010 and 2017 and computes th

e difference in populations as well as the percentage of change (in 2 decimal points).
Computers and Technology
1 answer:
Svetllana [295]3 years ago
3 0

Answer:

  1. import csv  
  2. with open('data.csv') as file:
  3.    records = csv.reader(file, delimiter = ",")
  4.    year = 2010
  5.    for row in records:
  6.        if (year == 2010):
  7.            print(str(year) + ": " + row[1])
  8.            previous_pop = int(row[1])
  9.            year = year + 1
  10.            print("\n")
  11.        else:
  12.            difference = abs(int(row[1]) - previous_pop)
  13.            percent = (difference / previous_pop) * 100
  14.            print(str(year) + ": " + row[1])
  15.            print("Difference: " + str(difference))
  16.            print("Percentage difference: " + str(round(percent,2)) + "%")
  17.            print("\n")
  18.            previous_pop = int(row[1])

Explanation:

Presume that there is a CSV file with 8 records. Each records have a year and population value.

Firstly, we can import the CSV module and use it to open and read the CSV file (Line 1 - 4)

Next we can use a for loop to traverse through the read data row by row (Line 6).

For the first row (year 2010), we can print out the year and population and assign the population to a variable previous_pop and increment the year by 1 (Line 9 -10).

When the year is more than 2010, we can start calculating the difference and percentage of difference of population (Line 13 -14). Then we can print out the details (Line 15 - 17) and repeat the same process in the next iteration.

You might be interested in
Discuss how classification systems have undergone several changes over a period of time.
katen-ka-za [31]

With time, the classification systems have undergone numerous alterations. Aristotle made the first attempt at classification. He divided plants into three categories: trees, shrubs, and herbs.

On the other side, red blood cell presence or absence was used to categorise animals. The known organisms cannot all be categorised using this technique.

As a result, Linnaeus provided a two-kingdom classification scheme. Kingdom Plantae and kingdom Animalia are its constituent parts. However, this approach did not distinguish between eukaryotes and prokaryotes or between unicellular and multicellular creatures. As a result, there were numerous species that fell outside of the two kingdoms.

Thus, in order to classify the three kingdoms, Ernest Haeckel divided unicellular eukaryotic organisms into a separate kingdom called Protista.

Learn more about classification systems:

brainly.com/question/28391550

#SPJ4

4 0
1 year ago
Write a function to sum the following series:
Phoenix [80]

Answer:

<u>C program to find the sum of the series( 1/2 + 2/3 + ... + i/i+1)</u>

#include <stdio.h>

double m(int i);//function declaration  

//driver function

int main() {

int i;

printf("Enter number of item in the series-\n");//Taking input from user

scanf("%d",&i);

double a= m(i);//Calling function

printf("sum=%lf",a);

return 0;

}

double m(int i)//Defining function

{

double j,k;

double sum=0;

for(j=1;j<i+1;j++)//Loop for the sum

{

k=j+1;

sum=sum+(j/k);

}

return sum;

}

<u>Output:</u>

Enter number of item in the series-5

sum=3.550000

5 0
3 years ago
The difference between tool bar and status bar​
Snowcat [4.5K]

Answer:

A toolbar offers easier access to tasks typically conducted within the application whereas in the status bar it is displayed at the lower side of the web browser screens and other application windows.

Explanation:

8 0
2 years ago
Jim has downloaded, installed, and is running too many programs simultaneously. At what pace will his computer be performing?
miss Akunina [59]

Answer:

Jim's computer will be performing at a slow pace

Explanation:

When you have too many programs open in the background, they eat up your cpu and core memory, causing your PC to lag. Jim's computer is likely to experience lag if he's running a bunch of programs at the same time.

6 0
3 years ago
Write the definition of a function words_typed, that receives two parameters. The first is a person's typing speed in words per
lianna [129]
<h2>Answer:</h2>

   //Method definition of words_typed

   //The return type is int

   //Takes two int parameters: typingSpeed and timeInterval

   public static int words_typed(int typingSpeed, int timeInterval) {

       //Get the number of words typed by  

       //finding the product of the typing speed and the time interval

       //and then dividing the result by 60 (since the typing speed is in "words

       // per minute"  and the time interval is in "seconds")

       int numberOfWords = typingSpeed * timeInterval / 60;

       

       //return the number of words

       return numberOfWords;

       

   }        //end of method declaration

<h2>Explanation:</h2>

The code above has been written in Java and it contains comments explaining each of the lines of the code. Please go through the comments.

8 0
4 years ago
Read 2 more answers
Other questions:
  • Which of these practices should you follow while creating your resume?
    13·2 answers
  • Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in
    11·1 answer
  • What pattern is a heart-shaped pattern that captures sound from a single direction, ?from the front?
    5·1 answer
  • This type of software works with end users, application software, and computer hardware to handle the majority of technical deta
    12·1 answer
  • The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have t
    15·1 answer
  • 1. What runs horizontally and is identified with numbers?
    12·2 answers
  • 1. (1 pt) Suppose you wish to run a program P with 37.5 x 109instructions on a 15 GHz machine with a CPI of 0.75. What is the ex
    9·1 answer
  • I have a question. This question will probably be deleted, but why do moderators keep deleting my answers when they are legitima
    13·1 answer
  • The __________ on a mouse is used to select or place the cursor where you want on the page
    13·1 answer
  • Different the policies and protocols in the industry
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!