# Allison Obourn
# CS 115, Autumn 2021
# Lecture 30

# This program reads in temperatures (real numbers) from a file named
# weather.txt that is in the same folder as this program. Assumes that
# the file has a single number on each line. It outputs the
# difference between each consecutive pair of temperatures in the file.
def main():
    file = open("weather.txt")
    data = file.readlines()

    # goes through the lines of the file, converting the numbers to
    # floats and computing the difference
    for i in range(0, len(data) - 1):
        data[i] = float(data[i])
        first = data[i]
        data[i + 1] = float(data[i + 1])
        second = data[i + 1]
        difference = second - first
        print(first, "to " + str(second) + ", change =", difference)
        
main()
