Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

must be in python have this code currently,but says cannot find file everytime i search import os def calculateAverage(name): file = open(name,r) name=input('enter the name

image text in transcribedimage text in transcribedimage text in transcribedmust be in python

have this code currently,but says cannot find file everytime i search

import os

def calculateAverage(name): file = open(name,"r") name=input('enter the name of file you would like to open') count = 0 sum = 0 for line in file: list = line.split(' ') sum = sum + int(list[1]) count = count + 1 print ("The avrage of the first column of readings is :",sum/count)

name = input("Enter file name :") if not os.path.isfile(name.upper()) and not os.path.isfile(name.upper()): print('File does not exit') else: if os.path.isFile(name.upper()): calculateAverage(name.upper()) if os.path.isFile(name.lower()): calculateAverage(name.lower())

e Scendho. Friends of The Shehahdodh River Revisife You are a volunteer member of an organization called the Friends of the Shenandoah River, which monitors water-quality issues in the Shenandoah Valley. Water quality data is gathered weekly at a number of sites along the river by various volunteers and the data is then uploaded to their website htt fosr.org/data). You have been asked to create a computer program that can read the data files that have been uploaded to the site, and then display statistical calculations based on that data You'd like to implement the following functionality: 1. You want to give the user a choice of one of two files, "Turbidity.txt" and "LabpH.txt" which you will find attached. Each file has in the first row the name of the item being measured and then an unknown number of readings. If you ask the user to enter the name of the file, be sure upper or lower case doesn't matter. (Note: the lower() and upper() method converts the case of a string, e.g. if you print 'turbidity.txt".upper() you will get TURBIDITY.TXT as output) Also, be sure you give a good message if the program can't find the file that the user requests. 2. You want to be able to read a file with any number of rows, but you won't know ahead of time how many rows of data will be in the file. You do know, however, that there will be no missing values, i.e. empty cells, in the data tables. (Hint: See chapter 6, or the lecture slides, on how to read from the file until the end of the file is reached. Which kind of loop will you need?) Your code may algorithmically look something like this

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: 3

blur-text-image

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago