Commit 1fdbda05 authored by Jack Pink's avatar Jack Pink
Browse files

initial commit of climate analysis code

import sys
import temp_conversion
import signal
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
script = sys.argv[0]
assert len(sys.argv) == 2, script + ": requires filename"
filename = sys.argv[1]
climate_data = open(filename, 'r')
for line in climate_data:
data = line.split(',')
if data[0][0] == '#':
# don't want to process comment lines, which start with '#'
# extract our max temperature in Fahrenheit - 4th column
fahr = float(data[3])
# don't process invalid temperature readings of -9999
if fahr != -9999:
celsius = temp_conversion.fahr_to_celsius(fahr)
kelvin = temp_conversion.fahr_to_kelvin(fahr)
print(str(celsius)+", "+str(kelvin))
"""A library to perform temperature conversions"""
def fahr_to_celsius(fahr):
"""Convert Fahrenheit to Celsius.
Uses standard Fahrenheit to Celsius formula
fahr -- the temperature in Fahrenheit
celsius = ((fahr - 32) * (5/9))
return celsius
def fahr_to_kelvin(fahr):
"""Convert Fahrenheight to Kelvin.
Uses standard Fahrenheit to Kelvin formula
fahr -- the temperature in Fahrenheit
kelvin = fahr_to_celsius(fahr) + 273.15
return kelvin
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment