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
Given the following code, what is output by the method call, mystery(6 * 8)? public static void mystery (int x[]) { System.out.p
____ [38]

Answer:

B

Explanation:

This question demonstrates the concept of method overloading

Method overloading means having different versions of the same method. In this case the method mystery() has three versions. The compiler is able to determine which method to call by their different parameters

The first implementation of mystery requires an array of integers as parameter

The second implementation requires an int variable

The third implementation requires a String

The Method call mystery(6 * 8) will output B because 6*8 evaluates to an integer which is the expected argument.

7 0
3 years ago
The state licensing bureau recently conducted a survey at Community Hospital. During this review, the surveyors determined that
marshall27 [118]

Answer: Opportunity for Improvement

Explanation:

Any healthcare organization, service, or process that does not reach the established standard or the customer's expectations, is an opportunity for improvement. Furthermore, the Improving Medicare Post-Acute Care Transformation Act (IMPACT) established a quality reporting program aimed to find those opportunities for improvement. Once the problem has been established, is prudent to place an action plan to achieve the desired performance improvement aim.

3 0
3 years ago
Write a python program to find the Area of Circle!<br>GRADE 8 CBSE​
barxatty [35]

Answer:

PI = 3.14

radius = float(input(' Please Enter the radius of a circle: '))

area = PI * radius * radius

circumference = 2 * PI * radius

Explanation:

i srs dont know i am so sorry i forgot but maybe this?

6 0
3 years ago
Most information security incidents will occur because of _________. Select one: a. Users who do not follow secure computing pra
nika2105 [10]

Answer:

Users who do not follow secure computing practices and procedures

Explanation:

Most data breaches that occur as a result of hacking and cyber-attacks get all the attention. However, the kind of mistakes that employees make in corporate situations can sometimes be very costly. Whether accidental or not, human error is the leading cause of most information security breaches. When you have proper policies, people working in big organizations, for instance, will know how they are to do with them. Organizations should put more effort on its employees. By ensuring that secure computing practices and procedures are followed, it will help guide the workforce more effectively.

4 0
3 years ago
Out of a list of the values 2, 45, 18, 22, 8, and 37, what result would the MAX function return?
Vika [28.1K]
37 most likely.
No programming language is specified, and you didn't put what the function is, so assuming it's already implemented, MAX should display the highest number.
8 0
3 years ago
Read 2 more answers
Other questions:
  • It is either snoming or below freezing
    10·1 answer
  • What list did poe appear on for the search engine lycos?
    11·1 answer
  • What are all the folders located on the DOCK called?
    11·1 answer
  • Programming assignment (100 pts): In the C++ programming language write a program capable of playing Tic-Tac-Toe against the use
    14·1 answer
  • Which field in a Transmission Control Protocol (TCP) header provides the next<br> expected segment?
    5·1 answer
  • Please help me with question 1!
    8·2 answers
  • Which command can be used to find errors on a hard drive​
    6·1 answer
  • File names should be limited to 144 characters.<br><br> true or false
    12·1 answer
  • We can save our data peremently on a
    7·2 answers
  • How long will the plant have been dead when 87.5 percent of its C-14 has become N-14?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!