Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Added previous code from previous problem if it helps!

Start a new program moving_ave_csv.py from your working version of moving_ave.py.
For the last program we will output a valid CSV file. Change your program so that instead of printing the values to the
screen (comment out the print statement) it writes the values to an output file that includes a simple one line header.
For simplicity your will not prompt the user for the output file name, you will always call it MovingAve.csv. Finally, add a
short column header to the output file: "Year,Value\n".
When you run your program with the following inputs it should produce this output:
Temperature anomaly filename:SacramentoTemps.csv
Enter window size:60
Opening the output file in a text editor should look like this:
Year, Value
1940, -0.2331
1941, -0.2169
1942, -0.2150
1943,-0.2228
1955,-Ø.1580
1956,-0.1420
1957, -0.1101
1958, -0.1017
Submit the completed program to Gradescope as moving_ave_csv.py
Gradescope will look for the output file named MovingAve.csv and include its contents at the end of the expected
output.
expand button
Transcribed Image Text:Start a new program moving_ave_csv.py from your working version of moving_ave.py. For the last program we will output a valid CSV file. Change your program so that instead of printing the values to the screen (comment out the print statement) it writes the values to an output file that includes a simple one line header. For simplicity your will not prompt the user for the output file name, you will always call it MovingAve.csv. Finally, add a short column header to the output file: "Year,Value\n". When you run your program with the following inputs it should produce this output: Temperature anomaly filename:SacramentoTemps.csv Enter window size:60 Opening the output file in a text editor should look like this: Year, Value 1940, -0.2331 1941, -0.2169 1942, -0.2150 1943,-0.2228 1955,-Ø.1580 1956,-0.1420 1957, -0.1101 1958, -0.1017 Submit the completed program to Gradescope as moving_ave_csv.py Gradescope will look for the output file named MovingAve.csv and include its contents at the end of the expected output.
file = input ("Temperature anomaly filename:")
listTemp = []
file = open(file,
rowCount = 0
%3D
for row in file:
row = row.strip("\n")
row = row.split(",")
if rowCount !=0:
%3D
listTemp.append (float(row [1]))
rowCount = rowCount + 1
k = int (input ("Enter window size:"))
for i in range (k , len(listTemp)- k):
ave = sum(listTemp [i - k: i + k + 1])/(2*k + 1)
year = 1880 + i
print ("{},{:.4f}".format(year , ave))
expand button
Transcribed Image Text:file = input ("Temperature anomaly filename:") listTemp = [] file = open(file, rowCount = 0 %3D for row in file: row = row.strip("\n") row = row.split(",") if rowCount !=0: %3D listTemp.append (float(row [1])) rowCount = rowCount + 1 k = int (input ("Enter window size:")) for i in range (k , len(listTemp)- k): ave = sum(listTemp [i - k: i + k + 1])/(2*k + 1) year = 1880 + i print ("{},{:.4f}".format(year , ave))
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY