n (comment out the print statement) it writes the values to an output fil implicity your will not prompt the user for the output file name, you will column header to the output file: "Year,Value\n". n you run your program with the following inputs it should produce this
n (comment out the print statement) it writes the values to an output fil implicity your will not prompt the user for the output file name, you will column header to the output file: "Year,Value\n". n you run your program with the following inputs it should produce this
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...
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5d321746-c77e-4de9-b25c-dd05ca6fd42f%2F6a6440d3-4107-4eaf-8b06-87c2d753c594%2F2p0cj2_processed.png&w=3840&q=75)
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))](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5d321746-c77e-4de9-b25c-dd05ca6fd42f%2F6a6440d3-4107-4eaf-8b06-87c2d753c594%2Fb7wkosq_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
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](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY