Practice 6

Question 1

The file monthly-sunspots.txt contains one floating point number per line. Write a program which opens the file, reads the numbers into a list or array, then plots the data as a line graph.

monthly-sunspots.txt

Question 2

The time() function returns the number of seconds which have elapsed since January 1 1970.

from time import time
print(time())

1609431989.253785

Write a program which writes the current time to the file current_time.txt. Investigate the difference between opening the file in write mode versus append mode.

Question 3

Write a program which creates 9 files named element_1.txt to element_9.txt containing the name and description of the first 9 chemical elements listed in the file periodic_table.csv. E.g., element_1.txt should contain:

Hydrogen
colorless gas

periodic_table.csv