Write a program which reads the data from sunspots.txt: sunspots.txt - Notepad File Edit Format View Help 18.5 11.8 19.7 31.6 26.6 1945 1946 1947 1948 1949 1950 37.3 37.4 24.6 34.0 71.3 46.3 28.4 55.2 92.0 87.5 81.0 83.5 79.6 115.1 112.7 115.7 112.7 136.2 127.4 128.2 145.5 153.0 161.0 224.2 166.3 166.6 216.4 195.0 191.7 155.0 148.3 130.1 107.3 103.8 222.5 194.8 203.6 184.3 205.0 174.6 166.3 129.9 177.1 153.3 228.0 198.8 190.7 147.4 154.5 153.6 163.7 183.7 172.2 190.9 152.1 125.8 117.4 134.6 139.5 129.8 99.3 104.7 106.8 65.4 77.1 72.8 71.2 49.0 89.6 91.7 85.4 58.3 55.6 85.2 50.8 56.7 42.9 23.3 27.3 22.2 36.0 39.4 53.2 26.1 22.5 22.5 33.5 7.9 24.8 10.9 19.6 6.4 23.1 15.7 7.2 1.7 1.6 8.0 0.6 0.2 0.2 2.1 8.1 0.3 4.7 8.0 7.7 1951 1952 53.8 54.0 38.6 21.8 4.0 1953 26.6 1954 0.1 0.3 ...and computes the average for each year, writing them to a file averages.txt (shown below) one per line: Year Average 1945 32.29 Submit both files: averages.txt and p41.py Hints: #Open the File to Read myFile = open('sunspots.txt', 'r') # Read the data from file into a list listOfLines myFile.read().splitlines() # Each list item is a new line from the file listItem = listOfLines [0].split() # split each line by spaces print (listItem) # shows list of strings ['1945', '18.5', '11.8',..., '28.4'] # Convert each of the strings to float in order to do math with them!
Write a program which reads the data from sunspots.txt: sunspots.txt - Notepad File Edit Format View Help 18.5 11.8 19.7 31.6 26.6 1945 1946 1947 1948 1949 1950 37.3 37.4 24.6 34.0 71.3 46.3 28.4 55.2 92.0 87.5 81.0 83.5 79.6 115.1 112.7 115.7 112.7 136.2 127.4 128.2 145.5 153.0 161.0 224.2 166.3 166.6 216.4 195.0 191.7 155.0 148.3 130.1 107.3 103.8 222.5 194.8 203.6 184.3 205.0 174.6 166.3 129.9 177.1 153.3 228.0 198.8 190.7 147.4 154.5 153.6 163.7 183.7 172.2 190.9 152.1 125.8 117.4 134.6 139.5 129.8 99.3 104.7 106.8 65.4 77.1 72.8 71.2 49.0 89.6 91.7 85.4 58.3 55.6 85.2 50.8 56.7 42.9 23.3 27.3 22.2 36.0 39.4 53.2 26.1 22.5 22.5 33.5 7.9 24.8 10.9 19.6 6.4 23.1 15.7 7.2 1.7 1.6 8.0 0.6 0.2 0.2 2.1 8.1 0.3 4.7 8.0 7.7 1951 1952 53.8 54.0 38.6 21.8 4.0 1953 26.6 1954 0.1 0.3 ...and computes the average for each year, writing them to a file averages.txt (shown below) one per line: Year Average 1945 32.29 Submit both files: averages.txt and p41.py Hints: #Open the File to Read myFile = open('sunspots.txt', 'r') # Read the data from file into a list listOfLines myFile.read().splitlines() # Each list item is a new line from the file listItem = listOfLines [0].split() # split each line by spaces print (listItem) # shows list of strings ['1945', '18.5', '11.8',..., '28.4'] # Convert each of the strings to float in order to do math with them!
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
This CSIS 9 Python.
Expert Solution
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 4 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education