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
andrey2020 [161]
3 years ago
13

Write a Python 3 program to read from a .csv file containing rates from power companies. Your program should determine the avera

ge commercial rate, and also display the information for the highest and lowest rates found.
Computers and Technology
1 answer:
aliya0001 [1]3 years ago
6 0

Answer:

In python:

file = open("rates.csv", "r")

ratecount = 0

ratesum = 0

mylist = []

rates = file.readlines()

for nums in rates:

     num = nums.rstrip('\n')

     mylist.append(int(num))

     for i in num:

           ratesum= ratesum + int(i)

           ratecount = ratecount + 1

print("Maximum Rate: "+str(max(mylist)))

print("Minimum Rate: "+str(min(mylist)))

print("Average Rate: "+str(ratesum/ratecount))

Explanation:

This opens the csv file

file = open("rates.csv", "r")

This initializes the number of rates in the file

ratecount = 0

This initializes the sum of the rates

ratesum = 0

This initializes an empty list

mylist = []

This reads the rates into lines

rates = file.readlines()

This iterates through the rates (as a string)

for nums in rates:

This removes the newline character \n in the rates

     num = nums.rstrip('\n')

This appends the rates (as an integer) to the empty list

     mylist.append(int(num))

The following counts the rates in the file and also sum them up

<em>      for i in num: </em>

<em>            ratesum= ratesum + int(i) </em>

<em>            ratecount = ratecount + 1 </em>

This prints the maximum of the rates

print("Maximum Rate: "+str(max(mylist)))

This prints the minimum of the rates

print("Minimum Rate: "+str(min(mylist)))

This calculates and prints the average rate

print("Average Rate: "+str(ratesum/ratecount))

You might be interested in
Jason needs to design the colors for a web site that make it easy to read. Which should he consider using?
ololo11 [35]

Answer: Dark background and light text.

Explanation:

Assuming when you mean by "light text", you mean by white text. This should be able to be readable by users visiting the site.

4 0
2 years ago
. Alex discovered a bunch of SATA drives in a box at the office and needs to check the contents. What can he do so that Windows
ZanzabumX [31]

You have to make sure the BIOS boot is set to the normal hard drive first, then plug in the SATA cable and power properly

8 0
3 years ago
Look at the data set below. {9, 12, 12, 15, 18, 20, 25} in this data set, what is the median
cluponka [151]

. Answer: Median: 15

8 0
3 years ago
Read 2 more answers
A project manager is working with a software development group to collect and evaluate user stories related to the organization’
MA_775_DIABLO [31]

Answer:

Answer: C Scrum

Explanation:

Answer: C Scrum would BEST support this objective, to collect and evaluate user stories related to the organization’s internally designed CRM tool.

3 0
3 years ago
Two friends can share 100 songs from their Bluetooth enabled mobile devices
Umnica [9.8K]

Answer:

A

Explanation:

If they are connected via bluetooth, you can share unlimited amounts of anything.

6 0
2 years ago
Other questions:
  • Vpns create a _____________ to transport information through public communications media.
    8·1 answer
  • Which option organizes tasks based on importance?
    12·1 answer
  • You are to create a program using Python that asks the user for a nonnegative number, then computes the mean and variance using
    15·1 answer
  • What is a sign of the brick and mortar and the virtual world meeting together?
    14·1 answer
  • Video is a medium that's looks real anyways, but is real________________.
    10·1 answer
  • Write a program in qbasic to accept a character and check it is vowel or consonant​
    14·1 answer
  • Given N lines of input, print the 3rd character from each line as a new line of output. It is guaranteed that each of the n line
    8·1 answer
  • Please its argent and I will give you BRAINLIEST ANSWER 6. How would you confirm that a colourless liquid given to you is pure w
    10·1 answer
  • Does anyone know what episode Hinata threatens useless sakura?
    9·1 answer
  • a) consider the binary number 11010010. what is the base-4 representation of (11010010)2? (there is a way to do this without con
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!