Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my assigment and my code I did everything but NOW I need to use FUNTIONS READ before my code the feedback from my

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribed

image text in transcribed

Here is my assigment and my code I did everything but NOW I need to use FUNTIONS "READ before my code the feedback from my teacher"

THIS IS MY CODE AND WORKS BUT I NEED TO USE FUNCTIONS PLEASE HELPL ME

Python 3

myFile = input("Please enter the data file: ")

newFile = open(myFile, "r")

count_lines = 0.0

average = 0.0

highest_comercial = 0.0 #highest value

lowest_comercial = 1.0 #lowest value

value = 0.0 #store the value of commercial in float

min_val = 1.0

total = 0.0 # get the total

information = ""

low_info = ""

for line in newFile:

comm_rate = line.split(",")

count_lines = count_lines + 1

if (comm_rate[6] != "comm_rate"):

# casting from string to float

value = float(comm_rate[6])

min_val = float(comm_rate[6])

total = value + total

if (highest_comercial

highest_comercial = value

information = line

if (lowest_comercial >= min_val):

lowest_comercial = min_val

low_info = line

count_lines = count_lines - 1

average = total/count_lines

print (" The average commercial rate is: {}".format(average))

print (" The highest rate is:")

words = information.split(",")

print("{} ({}, {}) - ${} ".format(words[2],words[0],words[3],highest_comercial))

print ("The lowest rate is:")

words1 = low_info.split(",")

print("{} ({}, {}) - ${}".format(words1[2],words1[0],words1[3],lowest_comercial))

02 Prove Assignment I. Overview This assignment will give you practice using Python to read from files and process information. II. Instructions Write a Python 3 program to read from a .csv file containing rates from power companies. Your program should determine the average commercial rate, and also display the information for the highest and lowest rates found. The data file you will use is freely available from data.gov. It lists the commercial (comm rate), industrial (ind rate), and residential (res rate) rates for each zip code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

ISBN: 0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

don't copy and paste if I will give 5 0 dislike

Answered: 1 week ago

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago