Last active
October 22, 2015 08:12
-
-
Save anirudhjayaraman/ece6215e119d03415464 to your computer and use it in GitHub Desktop.
List Manipulation Without NumPy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab | |
def loadfile(): | |
inFile = open('julyTemps.txt', 'r') | |
high =[]; low = [] | |
for line in inFile: | |
fields = line.split() | |
if len(fields) < 3 or not fields[0].isdigit(): | |
pass | |
else: | |
high.append(int(fields[1])) | |
low.append(int(fields[2])) | |
return low, high | |
def producePlot(lowTemps, highTemps): | |
diffTemps = [highTemps[i] - lowTemps[i] for i in range(len(lowTemps))] | |
pylab.title('Day by Day Ranges in Temperature in Boston in July 2012') | |
pylab.xlabel('Days') | |
pylab.ylabel('Temperature Ranges') | |
return pylab.plot(range(1,32),diffTemps) | |
producePlot(loadfile()[1], loadfile()[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment