Sense Hat internal temperature

I just happened to have a Sense Hat lying around here which wasn't doing anything so I decided to make it work for a living. It's now inside the print volume and is being used to monitor the ambient temperature inside the box.

The Python SenseHat marquee() function allows it to display the temperature (in Fahrenheit here) as it scrolls across the dot matrix display. It will also log the temperature readings to disk.

#!/usr/bin/python

from sense_hat import SenseHat
from datetime import datetime
import time
import arrow
sense = SenseHat()
gray = (48, 48, 48)
marquee = sense.show_message
f = open('./temp-data.csv', 'a');
try:
    while True:
        tC = round(sense.get_temperature(), 1) - 8.5
        tF = round(((tC * 9) / 5) + 32, 1)
        msg = "{0}".format(tF)
        marquee(msg, scroll_speed=0.2, text_colour=gray)
        msgPrint = '"' + datetime.now().strftime('%m/%d/%Y %H:%M') + '",' + msg + ',' + "{0}".format(tC)
        f.write(msgPrint + '\n')
        print(msgPrint)
        time.sleep(10)
finally:
    sense.clear()
    f.close()

How did you get this set up to start? I'm learning to input stuff via Putty but don't know how to insert this code correctly to run this function or adapt or create my own. any tips on how to get there? thanks!