file = input("Temperature anomaly filename:") listTemp = [] file = open(file, 'r') rowCount = 0 #Row steps for row in file: row = row.strip("\n") row = row.split(",") if rowCount !=0: 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])7(2*k + 1) year = 1880 + i print ("{},{:.4f}".format(year , ave)) file = listTemp = [] file = open(file, 'r') rowCount = 0 for row in file: row = row.strip("\n") row = row.split(",") if rowCount !=0: input ("Temperature anomaly filename:") %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 , %3D ave))

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Attached previous code.. don't know what adjustments to make to meet criteria for question (python)

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, -0.1580
1956, -0.1420
1957,-0.1101
1958, -0.1017
Transcribed Image Text: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, -0.1580 1956, -0.1420 1957,-0.1101 1958, -0.1017
file = input("Temperature anomaly filename:")
listTemp
file = open(file, 'r')
rowCount = 0
#Row steps
for row in file:
row = row.strip("\n")
row = row. split(",")
if rowCount !=0:
[]
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))
input ("Temperature anomaly filename:")
[]
file =
listTemp
file = open (file, 'r')
rowCount = 0
for row in file:
row.strip("\n")
row =
row.split(",")
if rowCount !=0:
listTemp.append (float(row [1] ))
rowCount = rowCount + 1
row =
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))
Ln: 1 Col: 0
Transcribed Image Text:file = input("Temperature anomaly filename:") listTemp file = open(file, 'r') rowCount = 0 #Row steps for row in file: row = row.strip("\n") row = row. split(",") if rowCount !=0: [] 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)) input ("Temperature anomaly filename:") [] file = listTemp file = open (file, 'r') rowCount = 0 for row in file: row.strip("\n") row = row.split(",") if rowCount !=0: listTemp.append (float(row [1] )) rowCount = rowCount + 1 row = 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)) Ln: 1 Col: 0
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY