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]
2 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]2 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
The term used to describe an electronic device, operating under the control of instructions stored in its own memory, that can a
nlexa [21]
The answer to this is Computer!!
3 0
2 years ago
A ____ transmits all data received to all network devices connected to it, regardless of which device the data is being sent to.
Alecsey [184]

A Hub transmits all data received to all network devices connected to it, regardless of which device the data exists being sent to.

<h3>What is Hub?</h3>

A hub stands for the connection point in a computer device where data from numerous directions converge and are then sent out in many directions to respective devices. A hub may even act as a switch by preventing distinct data packets from proceeding to a destination. There exist three types of network hubs: passive, active, and intelligent.

A network hub exists as a node that broadcasts data to every computer or Ethernet-based device connected to it. A hub stands less sophisticated than a switch, the latter of which can isolate data transmissions to specific devices. Network hubs stand best suited for small, simple local area network (LAN) environments.

Hence,  A Hub transmits all data received to all network devices connected to it, regardless of which device the data exists being sent to.

To learn more about Hub refer to:

brainly.com/question/25804256

#SPJ4

7 0
1 year ago
You are developing a Windows forms application used by a government agency. You need to develop a distinct user interface elemen
-BARSIC- [3]

Answer:

The answer is "Developing the custom control for the user interface"

Explanation:

The major difference between customized control & user control would be that it inherit throughout the inheritance tree at different levels. Usually, a custom power comes from the system. Windows. UserControl is a system inheritance.

Using accuracy up is the major reason for designing a custom UI control. Developers must know how to use the API alone without reading the code for your component. All public methods and features of a custom control will be included in your API.

6 0
2 years ago
What are the main purposes of regulatory policies? Check all that apply.
zhenek [66]
Hey there,
<span>- To make business competitive
- To limit and prevent monopolies
- To place regulations on prices.

Hope this helps ;))

~Top
</span>
5 0
3 years ago
Read 2 more answers
Which institution developed outside the limits of the written costitution of the united states ?
nignag [31]
The answer is D. Electoral College
4 0
2 years ago
Other questions:
  • Question 5
    5·1 answer
  • A user has been given Full Control permission to a shared folder. The user has been given Modify permission at the NTFS level to
    11·1 answer
  • The desktops of computers running the same OS all look the same
    8·1 answer
  • How many Iron molecules are in the compound Fe4O2?
    15·2 answers
  • Which types of files can be used to define Kubernetes manifest files? yaml, json, yaml and text files
    5·1 answer
  • 14. Which of the following information about the ESRT T-teen rating rating is FALSE?
    15·1 answer
  • Setting up a desktop computer for anAutoCADspecialist who needs a minimum of 125 GBram which operating system would be the best
    5·1 answer
  • Explain to Alana why she might not want to blast her boss on social media just yet.<br>​
    6·1 answer
  • Difference between a port and a connector
    10·1 answer
  • What would the input, process, outcome and feedback be for a class assignment
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!