Skip to content

Instantly share code, notes, and snippets.

@garyrh
Last active December 14, 2015 17:28
Show Gist options
  • Save garyrh/5121920 to your computer and use it in GitHub Desktop.
Save garyrh/5121920 to your computer and use it in GitHub Desktop.
High Temperature Diffrences in Boston (edX)
import pylab
pylab.figure(1)
pylab.title("High Temperature Differences for Boston in July")
pylab.xlabel("Days")
pylab.ylabel("Temp differences")
values = dict()
xvalues, yvalues = list(), list()
file = open('./julyTemps.txt', 'r')
for line in file:
try:
temps = [int(i) for i in line.split(" ") if i.strip("\n").isdigit()]
values[temps[0]] = temps[1:]
except:
continue
for key in values.keys():
if key == len(values.keys()):
break
xvalues.append(key+1)
yvalues.append(values[key+1][0]-values[key][0])
pylab.plot(xvalues, yvalues)
pylab.savefig("hightemps")
Boston July Temperatures
-------------------------
Day High Low
------------
1 91 70
2 84 69
3 86 68
4 84 68
5 83 70
6 80 68
7 86 73
8 89 71
9 84 67
10 83 65
11 80 66
12 86 63
13 90 69
14 91 72
15 91 72
16 88 72
17 97 76
18 89 70
19 74 66
20 71 64
21 74 61
22 84 61
23 86 66
24 91 68
25 83 65
26 84 66
27 79 64
28 72 63
29 73 64
30 81 63
31 73 63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment