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
Which can be used to enter and manipulate information in a database?<br><br> ANSWER: C) a form
alexgriva [62]

Answer:

a form

Explanation:

it says the answer already in the question

3 0
4 years ago
Why did they removed the watch video button to view answers?​
MA_775_DIABLO [31]

Answer:

Umm I’m not sure

Explanation:

7 0
3 years ago
Farm equipment that travels on public roads
solmaris [256]
I've seen tractors on the roads... if that's what you're looking for.
7 0
4 years ago
Read 2 more answers
So if brainly teaches me better why do we even have real life teachers??????
Katarina [22]

Answer:

i dont know maybe becuse the l.a.w says so?

Explanation:

7 0
3 years ago
Briefly describe the difference between problem solving and classical planning.
mixas84 [53]

Explanation: The difference present between the problem solving technique and the classical planning technique are as follows:-

  • Problem solving is the technique in which the possible solution outcomes are searched and then implemented to resolve the problem or aim towards solving it whereas classical planning is the planning of the possible solutions that are possible for the implementation.
  • problem solving is the complete method of plan execution whereas the classical planning is a type of backward planning that contains ideas for solving problem.

6 0
3 years ago
Other questions:
  • Consider the following JavaScript program:
    8·1 answer
  • How much mobile data does maps use
    6·1 answer
  • Your grandmother tells you a dollar doesn’t go as far as it used to. She says the “purchasing power” of a dollar is much less th
    13·1 answer
  • What is an examlple of cyberbullying
    5·1 answer
  • HELP URGENT
    12·2 answers
  • In cell h13, insert a pmt function to calculate the payments for students who want to pay for their trips in three installments.
    11·1 answer
  • I love this an this a a good app ❤️❤️❤️​
    5·2 answers
  • it has been said that television has little real educational value. what is your opinion on this issue?
    11·1 answer
  • What sort of technique would you use to sort 10,000 items using just 1000 available slot in your RAM?
    6·1 answer
  • Which of the following is NOT one of the three main ways to control a program when writing code?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!