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
You can tell when an image is selected, because its sizing handles will be visible. True or False
Ivenika [448]

This is true because you can go and check yourself in Word and you can click on an image and the sizing handles will appear.

hope that helps :)

8 0
3 years ago
Read 2 more answers
The function of an audio mixer is to _____. layer audio tracks at their ideal volume combine, control, and route audio signals f
larisa [96]

Answer: combine, control, and route audio signals from inputs to outputs

Explanation:

A audio mixer is refered to as the sound mixer or the mixing console and it's an electronic device that's used for mixing, and combining several audio signals and sounds.

The input to the console is the microphone. The audio mixer can also be used in controlling digital or analog signals. These are then summed up in producing output signals.

Therefore, the function of the audio mixer is to combine, control, and route audio signals from inputs to outputs.

7 0
2 years ago
In a wide area network (WAN), how would you troubleshoot an issue with the domain name system (DNS)?
NISA [10]
<span>C. Get the help of someone with specialized knowledge in the area.</span>
3 0
3 years ago
Read 2 more answers
If you know batch coding, can you see if there is anything wrong with this script, or if you can make any suggestions to modify
zzz [600]
There isn't an opening and closing parentheses for the else statement. PM me. I know a lot of batch...
8 0
3 years ago
A personal computer uses a number of chips mounted on a circuit board called
Vesnalui [34]
The answer is d.mother board 

7 0
3 years ago
Other questions:
  • For film editors, which task comes last in their workflow pattern?
    12·2 answers
  • All of the following are stages in the SDLC except _____.
    9·1 answer
  • • Write a program to find the maximum, minimum, and average score of players. The input to the program is a file containing play
    9·1 answer
  • 1. What is the main factor that affects Earth’s average temperature?
    12·1 answer
  • how many usable host addresses are available for each subnet when 4 bits are borrowed from a class C IP address
    11·1 answer
  • Binary Search:<br><br><br> 2 6 15 42 55 89 111 256
    6·1 answer
  • This is a human-made physical system.
    15·1 answer
  • What is the process called when programmers look for and fix errors in code? Analysis Debug Document Error check
    6·2 answers
  • Is Naab a system of an accounting system? A factory operations system? or both? explain your answer
    12·1 answer
  • A form of segmentation that is based on user usage rate, user status, purchase occasion, and benefits sought is _________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!