diff --git a/.vscode/launch.json b/.vscode/launch.json index a4a5c12..706e113 100755 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,213 +2,10 @@ "version": "0.2.0", "configurations": [ { - "name": "Attach (Remote Debug)", - "type": "python", - "request": "attach", - "localRoot": "${workspaceRoot}", - "remoteRoot": "${workspaceRoot}", - "port": 3000, - "secret": "my_secret", - "host": "localhost" - }, - { - "name": "Python", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${file}", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "PySpark", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "osx": { - "pythonPath": "${env:SPARK_HOME}/bin/spark-submit" - }, - "windows": { - "pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd" - }, - "linux": { - "pythonPath": "${env:SPARK_HOME}/bin/spark-submit" - }, - "program": "${file}", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Python Module", + "name": "Python: Current File", "type": "python", "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "module": "module.name", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Integrated Terminal/Console", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${file}", - "cwd": "", - "console": "integratedTerminal", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit" - ] - }, - { - "name": "External Terminal/Console", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${file}", - "cwd": "", - "console": "externalTerminal", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit" - ] - }, - { - "name": "Django", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/manage.py", - "cwd": "${workspaceRoot}", - "args": [ - "runserver", - "--noreload" - ], - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput", - "DjangoDebugging" - ] - }, - { - "name": "Flask", - "type": "python", - "request": "launch", - "stopOnEntry": false, - "pythonPath": "${config:python.pythonPath}", - "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter", - "cwd": "${workspaceRoot}", - "env": { - "FLASK_APP": "${workspaceRoot}/quickstart/app.py" - }, - "args": [ - "run", - "--no-debugger", - "--no-reload" - ], - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Flask (old)", - "type": "python", - "request": "launch", - "stopOnEntry": false, - "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/run.py", - "cwd": "${workspaceRoot}", - "args": [], - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Pyramid", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "args": [ - "${workspaceRoot}/development.ini" - ], - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput", - "Pyramid" - ] - }, - { - "name": "Watson", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/console.py", - "cwd": "${workspaceRoot}", - "args": [ - "dev", - "runserver", - "--noreload=True" - ], - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Attach (Remote Debug)", - "type": "python", - "request": "attach", - "localRoot": "${workspaceRoot}", - "remoteRoot": "${workspaceRoot}", - "port": 3000, - "secret": "my_secret", - "host": "localhost" + "program": "${file}" } ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index ea81c72..4d98ada 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "python.pythonPath": "D:\\Python36\\python3.exe", + "python.pythonPath": "D:\\Python\\Python36\\python.exe", "python.linting.pylintEnabled": false, "python.formatting.provider": "yapf" } \ No newline at end of file diff --git a/CVwithPy/.vscode/launch.json b/CVwithPy/.vscode/launch.json deleted file mode 100755 index 5b2c335..0000000 --- a/CVwithPy/.vscode/launch.json +++ /dev/null @@ -1,204 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Python", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${file}", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "PySpark", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "osx": { - "pythonPath": "${env:SPARK_HOME}/bin/spark-submit" - }, - "windows": { - "pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd" - }, - "linux": { - "pythonPath": "${env:SPARK_HOME}/bin/spark-submit" - }, - "program": "${file}", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Python Module", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "module": "module.name", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Integrated Terminal/Console", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${file}", - "cwd": "", - "console": "integratedTerminal", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit" - ] - }, - { - "name": "External Terminal/Console", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${file}", - "cwd": "", - "console": "externalTerminal", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit" - ] - }, - { - "name": "Django", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/manage.py", - "cwd": "${workspaceRoot}", - "args": [ - "runserver", - "--noreload" - ], - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput", - "DjangoDebugging" - ] - }, - { - "name": "Flask", - "type": "python", - "request": "launch", - "stopOnEntry": false, - "pythonPath": "${config:python.pythonPath}", - "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter", - "cwd": "${workspaceRoot}", - "env": { - "FLASK_APP": "${workspaceRoot}/quickstart/app.py" - }, - "args": [ - "run", - "--no-debugger", - "--no-reload" - ], - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Flask (old)", - "type": "python", - "request": "launch", - "stopOnEntry": false, - "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/run.py", - "cwd": "${workspaceRoot}", - "args": [], - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Pyramid", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "args": [ - "${workspaceRoot}/development.ini" - ], - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput", - "Pyramid" - ] - }, - { - "name": "Watson", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/console.py", - "cwd": "${workspaceRoot}", - "args": [ - "dev", - "runserver", - "--noreload=True" - ], - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Attach (Remote Debug)", - "type": "python", - "request": "attach", - "localRoot": "${workspaceRoot}", - "remoteRoot": "${workspaceRoot}", - "port": 3000, - "secret": "my_secret", - "host": "localhost" - } - ] -} \ No newline at end of file diff --git a/CVwithPy/BlurImage.py b/CVwithPy/BlurImage.py deleted file mode 100755 index 774bdc3..0000000 --- a/CVwithPy/BlurImage.py +++ /dev/null @@ -1,11 +0,0 @@ -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np -from scipy.ndimage import filters -import os - - -im = np.array(Image.open('test.jpg').convert('L')) -im2 = filters.gaussian_filter(im,5) -plt.imshow(im) -plt.show() diff --git a/CVwithPy/ContoursHistogram.py b/CVwithPy/ContoursHistogram.py deleted file mode 100755 index 4c06552..0000000 --- a/CVwithPy/ContoursHistogram.py +++ /dev/null @@ -1,36 +0,0 @@ -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np -#from Tkinter - -plt.hold(True) -#plt.figure(1) -plt.title('Plotting:"test.jpg"') -img = Image.open('test.jpg') -im = img.convert('L') -fig = plt.figure(1) -#original image -#plt.subplot(221) -ax = fig.add_subplot(221) -ax.imshow(img) -ax.set_title("The Original Image") -#plt.plot(im) -#grayed image -#plt.subplot(222) -#fig.gray() -ax = fig.add_subplot(222) -#fig = plt.gray() -#ax.imshow(fig) -ax.set_title("The Grey Image") -#contoured image -#plt.subplot(223) -ax = fig.add_subplot(223) -ax.contour(im,origin='image') -#ax.plot(fig3) -ax.set_title("The Contour Image") -#histogram image -#plt.subplot(224) -ax = fig.add_subplot(224) -#ax.hist(im.flatten(),128) -#ax.set_title("The hist Image") -plt.show() \ No newline at end of file diff --git a/CVwithPy/HelloWorld.py b/CVwithPy/HelloWorld.py deleted file mode 100755 index 992f7ff..0000000 --- a/CVwithPy/HelloWorld.py +++ /dev/null @@ -1,12 +0,0 @@ -#print("Hello World!"); - -def printResult(): - a = 6 - b = 5 - print(a+b) - -if __name__ == '__main__': - printResult() - - -""" """ \ No newline at end of file diff --git a/CVwithPy/ImageDerivatives.py b/CVwithPy/ImageDerivatives.py deleted file mode 100755 index 5448dea..0000000 --- a/CVwithPy/ImageDerivatives.py +++ /dev/null @@ -1,2 +0,0 @@ -from PIL import Image -import matplotlib.pyplot as plt diff --git a/CVwithPy/InteractiveInovation.py b/CVwithPy/InteractiveInovation.py deleted file mode 100755 index c490202..0000000 --- a/CVwithPy/InteractiveInovation.py +++ /dev/null @@ -1,12 +0,0 @@ -from PIL import Image -from pylab import * - -def InputPoints(): - im = array(Image.open('CVwithpy/test.jpg')) - imshow(im) - print('Please click 3 points') - x = ginput(3) - print('you clicked:',x) - show() - -InputPoints() \ No newline at end of file diff --git a/CVwithPy/Olaybeauty.py b/CVwithPy/Olaybeauty.py deleted file mode 100755 index be0b179..0000000 --- a/CVwithPy/Olaybeauty.py +++ /dev/null @@ -1,142 +0,0 @@ -import math -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np -from scipy.ndimage import filters -import os -import cv2 -import cv2.cv as cv - -def beauty(src,dst,center,radius,strength,m_strike): - #area to calculate - left = 0 if (center[0]-radius<0) else (center[0]-radius) - right = (src.shape[1]-1) if (center[0]+radius>src.shape[1]) else (center[0]+radius) - top = 0 if (center[1]-radius<0) else (center[1]-radius) - bottom = (src.shape[0]-1) if (center[1]+radius>src.shape[0]) else (center[1]+radius) - #radius - powerRadius = radius*radius - print "left,right,top,bottom",left,right,top,bottom - #implement the scale - i = left - j = top - #print i,j - for i in range(left,right): - offsetX = i - center[0] - for j in range(top,bottom): - offsetY = j - center[1] - XY = offsetX*offsetX+offsetY*offsetY - if XY <= powerRadius: - scaleFactor = 1.0 - float(XY)/float(powerRadius) - scaleFactor = 1 - float(strength)/100*scaleFactor - ''' - posX = int(offsetX * scaleFactor) + center[0] - posY = int(offsetY * scaleFactor) + center[1] - ''' - posX = offsetX * scaleFactor + center[0] - posY = offsetY * scaleFactor + center[1] - y = float(i)*scaleFactor - x = float(j)*scaleFactor - if posX < 0 : - posX = 0 - if posX+1 > src.shape[1]: - posX = src.shape[1]-1 - if posY < 0 : - posY = 0 - if posY+1 > src.shape[0]: - posY = src.shape[0]-1 - cy = np.ceil(posY) - fy = cy - 1 - cx = np.ceil(posX) - fx = cx - 1 - w1=(cx-posX)*(cy-posY) - w2=(posX-fx)*(cy-posY) - w3=(cx-posX)*(posY-fy) - w4=(posX-fx)*(posY-fy) - if (posX-np.floor(posX)>1e-6 or posY-np.floor(posY)>1e-6): - t=src[int(fy),int(fx)]*w1+src[int(fy),int(cx)]*w2+src[int(cy),int(fx)]*w3+src[int(cy),int(cx)]*w4 - t=np.ubyte(np.floor(t)) - #print t - dst[j,i]=t - else: - dst[j][i] = src[int(posY)][int(posX)] - ''' - #t=src[int(fy),int(fx)]*w1+src[int(fy),int(cx)]*w2+src[int(cy),int(fx)]*w3+src[int(cy),int(cx)]*w4 - #t=np.ubyte(np.floor(t)) - #dst[j][i] = t - #dst[j][i] = src[int(posY)][int(posX)] - #''' - - #dst = cv2.resize(dst,(dst.shape[0],dst.shape[1]),interpolation=cv2.INTER_CUBIC) - #box_data = np.array(dst) - #box_data = dst[:,bottom,right] - #eara = cv.rect() - #cv.SetImageROI(dst,(center[0], center[1], radius*2, radius*2)) - #plt.show(box_data) -def whitize(src,dst,beta): - h,w,c = src.shape - #print("image width:",w,",image height:",h) - i=j=0 - for i in range(0,w): - for j in range(0,h): - up0 = math.log(src[j][i][0]*(beta-1)+1) - up1 = math.log(src[j][i][1]*(beta-1)+1) - up2 = math.log(src[j][i][2]*(beta-1)+1) - dst[j][i][0] = up0/math.log(beta) - dst[j][i][1] = up1/math.log(beta) - dst[j][i][2] = up2/math.log(beta) - return dst - -#im = np.array(Image.open('CVwithPy/test.jpg').convert('L')) -im = cv2.imread("testImage05.jpg") -origin = cv2.imread("testImage05.jpg") -#im = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY); -#im2 = filters.gaussian_filter(im,5) -im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -origin = cv2.cvtColor(origin,cv2.COLOR_BGR2RGB) -src = im.copy() -dst = im.copy() -print "im",im.shape -print "src",src.shape -print "dst",dst.shape -#center(x,y) -#center1 = (340,480) -center1 = (260,430) -#center = (415,368) -print "center",center1 -#beauty(src,dst,center,radius,strength,m_strike) -beauty(src,dst,center1,60,30,10) -print("src id:",id(src)) -print("dst id:",id(dst)) -center2=(460,460) -src = dst.copy() -print("src copy id:",id(src)) -print("dst copy id:",id(dst)) -beauty(dst,src,center2,60,30,10) -#center3=(int(center1[0]*0.5+center2[0]*0.5),int(center1[1]*0.5+center2[1]*0.5)) -#beauty(dst,dst,center3,60,5,1) -#smooth image -#src = dst.copy() -#Mopi(src,dst,value1,value2,p) -#Mopi(dst,dst,3,4,50) -#dst = whitize(dst,dst,5) -dst = cv2.resize(dst,(dst.shape[0],dst.shape[1]),interpolation=cv2.INTER_LINEAR) -#dst = cv2.resize(dst,None,fx=2, fy=2,interpolation=cv2.INTER_LINEAR) -#dst = cv2.bilateralFilter(dst,16,16, 256, 32) -kernel = np.ones((1,1),np.float32)/1 -dst = cv2.filter2D(src,-1,kernel) -#src = cv2.cv.CreateImage(dst,dst,dst.channels()) -#cv2.cv.Smooth(src,dst,cv2.cv.CV_GAUSSIAN_5x5) -#kernel_erode = np.ones((5,5),np.uint8) -#dst = cv2.erode(dst,kernel,1) -#Mopi(dst,dst,3,4,50) -plt.subplot(121) -#origin[center1[1]+50][center1[0]-50] = (255,255,255) -plt.imshow(origin) -plt.subplot(122) -plt.imshow(dst) -plt.show() -#image write into disk -im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -dst = cv2.cvtColor(dst,cv2.COLOR_BGR2RGB) -cv2.imwrite("./before.png", im, [int(cv2.IMWRITE_PNG_COMPRESSION), 0]) -cv2.imwrite("./after.png", dst, [int(cv2.IMWRITE_PNG_COMPRESSION), 0]) \ No newline at end of file diff --git a/CVwithPy/OlaybeautyCMD0624.py b/CVwithPy/OlaybeautyCMD0624.py deleted file mode 100755 index dc53c21..0000000 --- a/CVwithPy/OlaybeautyCMD0624.py +++ /dev/null @@ -1,84 +0,0 @@ -import sys -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np -import os -import cv2 - -def beauty(src,dst,center,radius,strength,m_strike): - #area to calculate - left = 0 if (center[0]-radius<0) else (center[0]-radius) - right = (src.shape[1]-1) if (center[0]+radius>src.shape[1]) else (center[0]+radius) - top = 0 if (center[1]-radius<0) else (center[1]-radius) - bottom = (src.shape[0]-1) if (center[1]+radius>src.shape[0]) else (center[1]+radius) - #radius - powerRadius = radius*radius - print "left,right,top,bottom",left,right,top,bottom - #implement the scale - i = left - j = top - cout = 0 - print i,j - for i in range(left,right): - offsetX = i - center[0] - for j in range(top,bottom): - offsetY = j - center[1] - XY = offsetX*offsetX+offsetY*offsetY - if XY <= powerRadius: - scaleFactor = 1.0 - float(XY)/float(powerRadius) - scaleFactor = 1 - float(strength)/100*scaleFactor - posX = int(offsetX * scaleFactor) + center[0] - posY = int(offsetY * scaleFactor) + center[1] - if posX < 0 : - posX = 0 - if posX > src.shape[1]: - posX = src.shape[1]-1 - if posY < 0 : - posY = 0 - if posY > src.shape[0]: - posY = src.shape[0]-1 - dst[j][i] = src[posY][posX] - -def Mopi(src,dst,value1,value2,p): - # - dx = value1*5 - fc = value1*12.5 - temp1 = cv2.bilateralFilter(dst,dx, fc, fc) - temp2 = (temp1-dst+128) - temp3 = cv2.GaussianBlur(temp2,(2 * value2 - 1, 2 * value2 - 1),0,0) - temp4 = dst + 2 * temp3 - 255; - dst = (dst*(100 - p) + temp4*p) / 100; - #dst.copyTo(image); - - -#parameters from cmd -fileName,imgName,para1,para2,para3,para4=sys.argv -im = cv2.imread(imgName) -origin = cv2.imread(imgName) -im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -origin = cv2.cvtColor(origin,cv2.COLOR_BGR2RGB) -src = im.copy() -dst = im.copy() -center1 = (int(para1),int(para2)) -beauty(src,dst,center1,60,40,10) -center2=(int(para3),int(para4)) -src = dst.copy() -beauty(dst,src,center2,80,40,10) -#blur -kernel = np.ones((5,5),np.float32)/25 -dst = cv2.filter2D(src,-1,kernel) -#Mopi(src,dst,value1,value2,p) -Mopi(dst,dst,3,4,50) -dst = cv2.bilateralFilter(dst,9,9, 81, 18) -''' -plt.subplot(121) -plt.imshow(origin) -plt.subplot(122) -plt.imshow(dst) -plt.show() -''' -#image write into disk -im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -dst = cv2.cvtColor(dst,cv2.COLOR_BGR2RGB) -cv2.imwrite("./before.png", im, [int(cv2.IMWRITE_PNG_COMPRESSION), 0]) -cv2.imwrite("./after.png", dst, [int(cv2.IMWRITE_PNG_COMPRESSION), 0]) \ No newline at end of file diff --git a/CVwithPy/OlaybeautyCMD0625.py b/CVwithPy/OlaybeautyCMD0625.py deleted file mode 100755 index dc53c21..0000000 --- a/CVwithPy/OlaybeautyCMD0625.py +++ /dev/null @@ -1,84 +0,0 @@ -import sys -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np -import os -import cv2 - -def beauty(src,dst,center,radius,strength,m_strike): - #area to calculate - left = 0 if (center[0]-radius<0) else (center[0]-radius) - right = (src.shape[1]-1) if (center[0]+radius>src.shape[1]) else (center[0]+radius) - top = 0 if (center[1]-radius<0) else (center[1]-radius) - bottom = (src.shape[0]-1) if (center[1]+radius>src.shape[0]) else (center[1]+radius) - #radius - powerRadius = radius*radius - print "left,right,top,bottom",left,right,top,bottom - #implement the scale - i = left - j = top - cout = 0 - print i,j - for i in range(left,right): - offsetX = i - center[0] - for j in range(top,bottom): - offsetY = j - center[1] - XY = offsetX*offsetX+offsetY*offsetY - if XY <= powerRadius: - scaleFactor = 1.0 - float(XY)/float(powerRadius) - scaleFactor = 1 - float(strength)/100*scaleFactor - posX = int(offsetX * scaleFactor) + center[0] - posY = int(offsetY * scaleFactor) + center[1] - if posX < 0 : - posX = 0 - if posX > src.shape[1]: - posX = src.shape[1]-1 - if posY < 0 : - posY = 0 - if posY > src.shape[0]: - posY = src.shape[0]-1 - dst[j][i] = src[posY][posX] - -def Mopi(src,dst,value1,value2,p): - # - dx = value1*5 - fc = value1*12.5 - temp1 = cv2.bilateralFilter(dst,dx, fc, fc) - temp2 = (temp1-dst+128) - temp3 = cv2.GaussianBlur(temp2,(2 * value2 - 1, 2 * value2 - 1),0,0) - temp4 = dst + 2 * temp3 - 255; - dst = (dst*(100 - p) + temp4*p) / 100; - #dst.copyTo(image); - - -#parameters from cmd -fileName,imgName,para1,para2,para3,para4=sys.argv -im = cv2.imread(imgName) -origin = cv2.imread(imgName) -im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -origin = cv2.cvtColor(origin,cv2.COLOR_BGR2RGB) -src = im.copy() -dst = im.copy() -center1 = (int(para1),int(para2)) -beauty(src,dst,center1,60,40,10) -center2=(int(para3),int(para4)) -src = dst.copy() -beauty(dst,src,center2,80,40,10) -#blur -kernel = np.ones((5,5),np.float32)/25 -dst = cv2.filter2D(src,-1,kernel) -#Mopi(src,dst,value1,value2,p) -Mopi(dst,dst,3,4,50) -dst = cv2.bilateralFilter(dst,9,9, 81, 18) -''' -plt.subplot(121) -plt.imshow(origin) -plt.subplot(122) -plt.imshow(dst) -plt.show() -''' -#image write into disk -im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -dst = cv2.cvtColor(dst,cv2.COLOR_BGR2RGB) -cv2.imwrite("./before.png", im, [int(cv2.IMWRITE_PNG_COMPRESSION), 0]) -cv2.imwrite("./after.png", dst, [int(cv2.IMWRITE_PNG_COMPRESSION), 0]) \ No newline at end of file diff --git a/CVwithPy/OlaybeautyCMD0707.py b/CVwithPy/OlaybeautyCMD0707.py deleted file mode 100755 index 13e87b4..0000000 --- a/CVwithPy/OlaybeautyCMD0707.py +++ /dev/null @@ -1,103 +0,0 @@ -#import sys -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np -import os -import cv2 - -def beauty(src,dst,center,radius,strength,m_Stride): - #area to calculate - left = 0 if (center[0]-radius<0) else (center[0]-radius) - right = (src.shape[1]-1) if (center[0]+radius>src.shape[1]) else (center[0]+radius) - top = 0 if (center[1]-radius<0) else (center[1]-radius) - bottom = (src.shape[0]-1) if (center[1]+radius>src.shape[0]) else (center[1]+radius) - #radius - powerRadius = radius*radius - #print "left,right,top,bottom",left,right,top,bottom - #implement the scale - i = left - j = top - cout = 0 - #print i,j - for i in range(left,right): - offsetX = i - center[0] - for j in range(top,bottom): - offsetY = j - center[1] - XY = offsetX*offsetX+offsetY*offsetY - if XY <= powerRadius: - scaleFactor = 1.0 - float(XY)/float(powerRadius) - scaleFactor = 1.0 - float(strength)/100*scaleFactor - posX = offsetX * scaleFactor + center[0] - posY = offsetY * scaleFactor + center[1] - if posX-1 < 0 : - posX = 0 - if posX+1 > src.shape[1]: - posX = src.shape[1]-1 - if posY-1 < 0 : - posY = 0 - if posY+1 > src.shape[0]: - posY = src.shape[0]-1 - cy = np.ceil(posY) - fy = cy - 1 - cx = np.ceil(posX) - fx = cx - 1 - w1=(cx-posX)*(cy-posY) - w2=(posX-fx)*(cy-posY) - w3=(cx-posX)*(posY-fy) - w4=(posX-fx)*(posY-fy) - if (posX-np.floor(posX)>1e-6 or posY-np.floor(posY)>1e-6): - t=src[int(fy),int(fx)]*w1+src[int(fy),int(cx)]*w2+src[int(cy),int(fx)]*w3+src[int(cy),int(cx)]*w4 - t=np.ubyte(np.floor(t)) - dst[j,i]= t - else: - #dst[j][i] = 0 - dst[j][i] = src[int(posY)][int(posX)] - -def Whitize(src): - i=j=0 - for i in range(src.shape[0:1]): - for j in range(src.shape.pop[0:1]): - print (j,i) - -#parameters from cmd -#fileName,imgName,para1,para2,para3,para4,para5,para6=sys.argv -''' -''' -imgName = "testImage05.jpg" -para1 = 260 -para2 = 430 -para3 = 460 -para4 = 460 -para5 = 90 -para6 = 30 - -im = cv2.imread(imgName) -origin = cv2.imread(imgName) -im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -origin = cv2.cvtColor(origin,cv2.COLOR_BGR2RGB) -src = im.copy() -dst = im.copy() -center1 = (int(para1),int(para2)) -beauty(src,dst,center1,para5,para6,2) -center2=(int(para3),int(para4)) -src = dst.copy() -beauty(dst,src,center2,para5,para6,2) - -Whitize(dst) -#blur -kernel = np.ones((1,1),np.float32)/1 -dst = cv2.filter2D(src,-1,kernel) -dst = cv2.medianBlur(dst,3) -dst = cv2.bilateralFilter(dst,9, 15, 15) -#image write into disk -#im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -#dst = cv2.cvtColor(dst,cv2.COLOR_GRAY2RGB) -plt.subplot(121) -#origin[center1[1]+50][center1[0]-50] = (255,255,255) -plt.imshow(origin) -plt.subplot(122) -plt.imshow(dst) -plt.show() -#cv2.imwrite("./before.png", im, [int(cv2.IMWRITE_PNG_COMPRESSION), 0]) -cv2.imwrite("./after.png", dst, [int(cv2.IMWRITE_PNG_COMPRESSION), 0]) -cv2.imwrite("./after1.png", dst, [int(cv2.IMWRITE_PNG_COMPRESSION), 9]) \ No newline at end of file diff --git a/CVwithPy/PCA.py b/CVwithPy/PCA.py deleted file mode 100755 index 6fca433..0000000 --- a/CVwithPy/PCA.py +++ /dev/null @@ -1,21 +0,0 @@ -from PIL import Image -from pylab import * -from numpy import * - -def pca_book(X): - num_data,dim = X.shape - mean_X = X.mean(axis = 0) - X = X - mean_X - if dim > num_data: - M=dot(X,X.T) - e,EV = linalg.eigh(M) - temp = dot(X.T,EV).T - V = temp[::-1] - S = sqrt(e)[::-1] - #norm - for i in range(V.shape[1]): - V[:,i] /= linalg.norm(V[:,i]) - else: - U,S,V = linalg.svd(X) - V = V[:num_data] - return V,S,mean_X \ No newline at end of file diff --git a/CVwithPy/PCA.pyc b/CVwithPy/PCA.pyc deleted file mode 100755 index a761c85..0000000 Binary files a/CVwithPy/PCA.pyc and /dev/null differ diff --git a/CVwithPy/PCATest.py b/CVwithPy/PCATest.py deleted file mode 100755 index b00b408..0000000 --- a/CVwithPy/PCATest.py +++ /dev/null @@ -1,23 +0,0 @@ -from PIL import Image -from numpy import * -from pylab import* -from imtools import * -import PCA - -imlist = get_imlist('imlist/') - -im = array(Image.open(imlist[0])) -m,n = im.shape[0:2] -imnbr = len(imlist) -gray() -immatrix = array([array(Image.open(im)).flatten() for im in imlist],'f') -#perform PCA -V,S,immean = PCA.pca_book(immatrix) -#figure() -subplot(2,4,1) -imshow(immean.reshape(m,n,-1)) -for i in range(imnbr-1): - subplot(2,4,i+2) - imshow(V[i].reshape(m,n,-1)) - -show() \ No newline at end of file diff --git a/CVwithPy/PILTest01.py b/CVwithPy/PILTest01.py deleted file mode 100755 index 22344fa..0000000 --- a/CVwithPy/PILTest01.py +++ /dev/null @@ -1,3 +0,0 @@ -from PIL import Image -pil_im =Image.open("test.jpg").convert('L') -pil_im.show() \ No newline at end of file diff --git a/CVwithPy/PlottingTest.py b/CVwithPy/PlottingTest.py deleted file mode 100755 index c03a3c6..0000000 --- a/CVwithPy/PlottingTest.py +++ /dev/null @@ -1,17 +0,0 @@ -from PIL import Image -from pylab import * - -def showImage(): - im = Image.open('test.jpg') - imshow(im) - - x = [100,100,400,400] - y = [200,500,200,500] - - plot(x,y,'r*') - plot(x[:2],y[:2]) - - title('Plotting:"test.jpg"') - show() - -showImage() \ No newline at end of file diff --git a/CVwithPy/after.png b/CVwithPy/after.png deleted file mode 100755 index fcc773f..0000000 Binary files a/CVwithPy/after.png and /dev/null differ diff --git a/CVwithPy/after1.png b/CVwithPy/after1.png deleted file mode 100755 index a00317a..0000000 Binary files a/CVwithPy/after1.png and /dev/null differ diff --git a/CVwithPy/before.png b/CVwithPy/before.png deleted file mode 100755 index d4b7715..0000000 Binary files a/CVwithPy/before.png and /dev/null differ diff --git a/CVwithPy/imtools.py b/CVwithPy/imtools.py deleted file mode 100755 index 6c5a603..0000000 --- a/CVwithPy/imtools.py +++ /dev/null @@ -1,39 +0,0 @@ -from PIL import Image -import matplotlib.pyplot as plt -from pylab import * -import os - -def get_imlist(path): - return [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')] - -def imresize(im,sz): - pil_im = Image.fromarray(uint8(im)) - return array(pil_im.resize(sz)) - -def histeq(im,nbr_bins=256): - - # get image histogram - imhist,bins = histogram(im.flatten(),nbr_bins,normed=True) - cdf = imhist.cumsum() # cumulative distribution function - cdf = 255 * cdf / cdf[-1] # normalize - - # use linear interpolation of cdf to find new pixel values - im2 = interp(im.flatten(),bins[:-1],cdf) - - return im2.reshape(im.shape), cdf - -def compute_average(imlist): - averageim = array(Image.open(imlist[0]),'f') - - for imname in imlist[1:]: - try: - averageim += array(Image.open(imname)) - except: - print imname + '...skiped' - averageim /= len(imlist) - - return array(averageim,'uint8') - - - - diff --git a/CVwithPy/imtools.pyc b/CVwithPy/imtools.pyc deleted file mode 100755 index e048405..0000000 Binary files a/CVwithPy/imtools.pyc and /dev/null differ diff --git a/CVwithPy/integralresult.jpg b/CVwithPy/integralresult.jpg deleted file mode 100755 index f46e187..0000000 Binary files a/CVwithPy/integralresult.jpg and /dev/null differ diff --git a/CVwithPy/pca_graylevel.py b/CVwithPy/pca_graylevel.py deleted file mode 100755 index 9277924..0000000 --- a/CVwithPy/pca_graylevel.py +++ /dev/null @@ -1,28 +0,0 @@ -from PIL import Image -from pylab import * -from numpy import * - -from PCV.tools import imtools, pca - -# Get list of images and their size -imlist = imtools.get_imlist('imlist/') # fontimages.zip is part of the book data set -im = array(Image.open(imlist[0])) # open one image to get the size -m,n = im.shape[:2] - -# Create matrix to store all flattened images -immatrix = array([array(Image.open(imname)).flatten() for imname in imlist],'f') - -# Perform PCA -V,S,immean = pca.pca(immatrix) - -# Show the images (mean and 7 first modes) -# This gives figure 1-8 (p15) in the book. -figure() -gray() -subplot(2,4,1) -imshow(immean.reshape(m,-1)) -for i in range(7): - print i - subplot(2,4,i+2) - imshow(V[i].reshape(m,-1)) -show() diff --git a/CVwithPy/pca_new.py b/CVwithPy/pca_new.py deleted file mode 100755 index 799067e..0000000 --- a/CVwithPy/pca_new.py +++ /dev/null @@ -1,16 +0,0 @@ -from PIL import Image -import pylab as plt -import numpy as np - -def pca(X,k=1): - d,n = X.shape - mean_X = np.mean(X,axis=1) - print 'mean_X=',mean_X - X = X - mean_X - C = np.dot(X,X.T) - e,EV = np.linalg.eig(np.mat(C)) - print 'C=',C - e_idx = np.argsort(-e)[:k] - EV_main = EV[:,e_idx] - low_X = np.dot(EV_main.T,X) - return low_X,EV_main,mean_X \ No newline at end of file diff --git a/CVwithPy/pca_new.pyc b/CVwithPy/pca_new.pyc deleted file mode 100755 index b5b4177..0000000 Binary files a/CVwithPy/pca_new.pyc and /dev/null differ diff --git a/CVwithPy/pca_new_test.py b/CVwithPy/pca_new_test.py deleted file mode 100755 index ae455af..0000000 --- a/CVwithPy/pca_new_test.py +++ /dev/null @@ -1,23 +0,0 @@ -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np -from pca_new import pca -from PCA import pca_book - -imX = np.array(Image.open('CVwithPy/test.jpg').convert('L')) -n,m = imX.shape[0:2] -points = [] -for i in range(n): - for j in range(m): - if imX[i,j] < 128: - points.append([float(j),float(n)-float(i)]) -imX = np.mat(points).T -print 'im_X=',imX,'shape=',imX.shape - -low_X,EV_main,mean_X = pca(imX) -recon_X = np.dot(EV_main,low_X) + mean_X -fig = plt.figure() -ax = fig.add_subplot(111) -ax.scatter(imX[0].A[0],imX[1].A[0],s=1,alpha=0.5) -ax.scatter(recon_X[0].A[0], recon_X[1].A[0],marker='o',s=100,c='blue',edgecolors='white') -plt.show() \ No newline at end of file diff --git a/CVwithPy/test.jpg b/CVwithPy/test.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/CVwithPy/test.jpg and /dev/null differ diff --git a/CVwithPy/testImage.jpg b/CVwithPy/testImage.jpg deleted file mode 100755 index 942f499..0000000 Binary files a/CVwithPy/testImage.jpg and /dev/null differ diff --git a/CVwithPy/testImage01.jpg b/CVwithPy/testImage01.jpg deleted file mode 100755 index b9bb2d2..0000000 Binary files a/CVwithPy/testImage01.jpg and /dev/null differ diff --git a/CVwithPy/testImage02.jpg b/CVwithPy/testImage02.jpg deleted file mode 100755 index 3307a65..0000000 Binary files a/CVwithPy/testImage02.jpg and /dev/null differ diff --git a/CVwithPy/testImage03.jpg b/CVwithPy/testImage03.jpg deleted file mode 100755 index 6f9fb82..0000000 Binary files a/CVwithPy/testImage03.jpg and /dev/null differ diff --git a/CVwithPy/testImage04.jpg b/CVwithPy/testImage04.jpg deleted file mode 100755 index 66cbe33..0000000 Binary files a/CVwithPy/testImage04.jpg and /dev/null differ diff --git a/CVwithPy/testImage05.jpg b/CVwithPy/testImage05.jpg deleted file mode 100755 index c0fbb12..0000000 Binary files a/CVwithPy/testImage05.jpg and /dev/null differ diff --git a/FaceDetect/imlist/test 2 copy 12.jpg b/FaceDetect/imlist/test 2 copy 12.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/FaceDetect/imlist/test 2 copy 12.jpg and /dev/null differ diff --git a/FaceDetect/imlist/test 2 copy 13.jpg b/FaceDetect/imlist/test 2 copy 13.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/FaceDetect/imlist/test 2 copy 13.jpg and /dev/null differ diff --git a/FaceDetect/imlist/test 2 copy 14.jpg b/FaceDetect/imlist/test 2 copy 14.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/FaceDetect/imlist/test 2 copy 14.jpg and /dev/null differ diff --git a/FaceDetect/imlist/test 2 copy 15.jpg b/FaceDetect/imlist/test 2 copy 15.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/FaceDetect/imlist/test 2 copy 15.jpg and /dev/null differ diff --git a/FaceDetect/imlist/test 2 copy 16.jpg b/FaceDetect/imlist/test 2 copy 16.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/FaceDetect/imlist/test 2 copy 16.jpg and /dev/null differ diff --git a/FaceDetect/imlist/test 2 copy.jpg b/FaceDetect/imlist/test 2 copy.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/FaceDetect/imlist/test 2 copy.jpg and /dev/null differ diff --git a/FaceDetect/imlist/test 2.jpg b/FaceDetect/imlist/test 2.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/FaceDetect/imlist/test 2.jpg and /dev/null differ diff --git a/FaceDetect/imlist/test.jpg b/FaceDetect/imlist/test.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/FaceDetect/imlist/test.jpg and /dev/null differ diff --git a/FaceDetect/imtools.py b/FaceDetect/imtools.py deleted file mode 100755 index 6c5a603..0000000 --- a/FaceDetect/imtools.py +++ /dev/null @@ -1,39 +0,0 @@ -from PIL import Image -import matplotlib.pyplot as plt -from pylab import * -import os - -def get_imlist(path): - return [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')] - -def imresize(im,sz): - pil_im = Image.fromarray(uint8(im)) - return array(pil_im.resize(sz)) - -def histeq(im,nbr_bins=256): - - # get image histogram - imhist,bins = histogram(im.flatten(),nbr_bins,normed=True) - cdf = imhist.cumsum() # cumulative distribution function - cdf = 255 * cdf / cdf[-1] # normalize - - # use linear interpolation of cdf to find new pixel values - im2 = interp(im.flatten(),bins[:-1],cdf) - - return im2.reshape(im.shape), cdf - -def compute_average(imlist): - averageim = array(Image.open(imlist[0]),'f') - - for imname in imlist[1:]: - try: - averageim += array(Image.open(imname)) - except: - print imname + '...skiped' - averageim /= len(imlist) - - return array(averageim,'uint8') - - - - diff --git a/FaceDetect/imtools.pyc b/FaceDetect/imtools.pyc deleted file mode 100755 index 32cf8f4..0000000 Binary files a/FaceDetect/imtools.pyc and /dev/null differ diff --git a/FaceDetect/pca_face.py b/FaceDetect/pca_face.py deleted file mode 100755 index 43c9d7b..0000000 --- a/FaceDetect/pca_face.py +++ /dev/null @@ -1,48 +0,0 @@ -#import modules -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np -from imtools import get_imlist -import os - -impaths = get_imlist('imlist/') -im = np.array(Image.open(impaths[0]).convert('L')) -m,n = im.shape[0:2] -print 'm,n = ' , m , n - -X = np.mat([np.array(Image.open(impath)).flatten() for impath in impaths]).T -print 'X.shape=',X.shape - -def pca(X): - dim,num_data = X.shape - print dim,num_data - mean_X = X.mean(axis=0) - X = X - mean_X - - M = np.dot(X.T,X) - e,EV = np.linalg.eigh(M) - print 'e=', e.shape,e - print 'EV=', EV.shape,EV - - tmp = np.dot(X,EV) - print 'tmp=',tmp - V = tmp[::-1] - print 'V=',V.shape,V - - for i in range(EV.shape[1]): - V[:,i] /= np.linalg.norm(EV[:,i]) - - #print '(V,EV,mean_X)',V,EV,mean_X - - return V,EV,mean_X - -#pca(X) -V,EV,mean_X = pca(X) -plt.gray() -plt.subplot(241) -plt.imshow(im.reshape(285,-1)) -for i in range(7): - plt.subplot(2,4,i+2) - print 'V[',i,']=',V[i] - plt.imshow(V[i].reshape(285,-1)) -plt.show() \ No newline at end of file diff --git a/OPENCV/.DS_Store b/OPENCV/.DS_Store deleted file mode 100644 index 5c4d67a..0000000 Binary files a/OPENCV/.DS_Store and /dev/null differ diff --git a/OPENCV/CV3withPy/chapter01/data_format.py b/OPENCV/CV3withPy/chapter01/data_format.py deleted file mode 100644 index b6e2be4..0000000 --- a/OPENCV/CV3withPy/chapter01/data_format.py +++ /dev/null @@ -1,13 +0,0 @@ -import numpy as np -import cv2 - -img = np.zeros((3, 3), dtype=np.uint8) -print("create image array with numpy moudle") -print(img) -print(img.dtype) -print(img.shape) -img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) -print("convert image array into opencv3 image data") -print(img) -print(img.dtype) -print(img.shape) \ No newline at end of file diff --git a/OPENCV/CV3withPy/chapter01/imread.py b/OPENCV/CV3withPy/chapter01/imread.py deleted file mode 100644 index d8324d2..0000000 --- a/OPENCV/CV3withPy/chapter01/imread.py +++ /dev/null @@ -1,16 +0,0 @@ -import cv2 - - -def get_image_from_path(path, filename): - # with cv2.imread(path+filename) as image: - # cv2.write(path+"newImage.jpg",image) - image = cv2.imread(path + filename) - cv2.imwrite(path + "newImage.jpg", image) - - -def main(): - get_image_from_path("./OPENCV/ImageData/", "test.jpg") - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/OPENCV/CV3withPy/chapter01/random_image_create.py b/OPENCV/CV3withPy/chapter01/random_image_create.py deleted file mode 100644 index 765d87f..0000000 --- a/OPENCV/CV3withPy/chapter01/random_image_create.py +++ /dev/null @@ -1,12 +0,0 @@ -import cv2 -import numpy as np -import os - -random_byte_array = bytearray(os.urandom(120000)) -flat_numpy_array = np.array(random_byte_array) - -gray_image = flat_numpy_array.reshape(300, 400) -cv2.imwrite('./OPENCV/ImageData/output/random_gray.png', gray_image) - -bgr_image = flat_numpy_array.reshape(100, 400, 3) -cv2.imwrite('./OPENCV/ImageData/output/random_color.png', bgr_image) \ No newline at end of file diff --git a/OPENCV/CV3withPy/chapter01/video_read.py b/OPENCV/CV3withPy/chapter01/video_read.py deleted file mode 100644 index 6cc6b69..0000000 --- a/OPENCV/CV3withPy/chapter01/video_read.py +++ /dev/null @@ -1,2 +0,0 @@ -import cv2 - diff --git a/OPENCV/CVImageIO.py b/OPENCV/CVImageIO.py deleted file mode 100755 index 782ad72..0000000 --- a/OPENCV/CVImageIO.py +++ /dev/null @@ -1,32 +0,0 @@ -import cv2 -import numpy as np -from matplotlib import pyplot as plt -from PIL import Image -""" -im = cv2.imread('test.jpg',0) -#h,w = im.shape[:2] -print h,m - -cv2.imshow('test.jpg',im) -""" -img = cv2.imread('./OPENCV/test.jpg',1) -im = Image.open('./OPENCV/test.jpg') - -while True: - #cv2.namedWindow("Imread Test Window") - cv2.imshow("Imread Test Window",img) - imRGB = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) - print 'cv2.imread',img.shape - #print 'Image.open' , im - #im = img[:, :, (2, 1, 0)] - plt.imshow(imRGB) - plt.show("Pyplot Show Image") - if cv2.waitKey(10) == 27: - break - - -#img = Image.open("test.jpg") -#plt.imshow(img, cmap='gray', interpolation='bicubic') -#plt.imshow(img) -#plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis -#plt.show() \ No newline at end of file diff --git a/OPENCV/CalcOpticalFlow.py b/OPENCV/CalcOpticalFlow.py deleted file mode 100755 index cdcdc6c..0000000 --- a/OPENCV/CalcOpticalFlow.py +++ /dev/null @@ -1,43 +0,0 @@ -import cv2 -import numpy as np - -"""draw the flow""" -def draw_flow(im,flow,step=16): - """""" - h,w = im.shape[:2] - y,x = np.mgrid[step/2:h:step,step/2:w:step].reshape(2,-1).astype(np.int32) - fx,fy = flow[y,x].T - - lines = np.vstack([x,y,x+fx,y+fy]).T.reshape(-1,2,2) - lines = np.int32(lines) - - vis = cv2.cvtColor(im,cv2.COLOR_GRAY2BGR) - for (x1,y1),(x2,y2) in lines: - cv2.line(vis,(x1,y1),(x2,y2),(0,255,0),1) - cv2.circle(vis,(x1,y1),1,(0,255,0),-1) - - return vis - - -#the main video capture segment -cap = cv2.VideoCapture(0) -#cap.set(CV_CAP_PROP_FRAME_WIDTH,640) -#cap.set(CV_CAP_PROP_FRAME_HEIGHT,360) -ret,im = cap.read() -prev_gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) - -while True : - ret,im = cap.read() - #cap.set(CV_CAP_PROP_FRAME_WIDTH,640) - #cap.set(CV_CAP_PROP_FRAME_HEIGHT,360) - #print ret - gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) - - #flow = cv2.calcOpticalFlowFarneback(prevgray, gray, 0.5, 3, 15, 3, 5, 1.2, 0) - flow = cv2.calcOpticalFlowFarneback(prev_gray,gray,None,0.5,3,15,3,5,1.2,1) - # flow = cv2.calcOpticalFlowFarneback(prev_gray,gray,flow=None,pyr_scale=0.5, levels=1, winsize=15,iterations=2,poly_n=5, poly_sigma=1.1, flags=0) - prev_gray = gray - - cv2.imshow('Optical Flow',draw_flow(gray,flow)) - if cv2.waitKey(10) == 27: - break \ No newline at end of file diff --git a/OPENCV/Cartoonize.py b/OPENCV/Cartoonize.py deleted file mode 100755 index de16917..0000000 --- a/OPENCV/Cartoonize.py +++ /dev/null @@ -1,28 +0,0 @@ -#coding = utf-8 -#move scripts into the OPENCV folder/finder -import cv2 -import numpy as np -cap = cv2.VideoCapture(0) - -print("完成了视频的捕捉") - -#application dealing with camera main-loop -#exit when user press ESC key -while True: - if (not cap.isOpened()): - break - ret, im = cap.read() - #resize the width and height - # convert video stream into gray color space - gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) - #median blur PS:the size must be a odd number : return [retval,dst] - median_blur = cv2.medianBlur(gray, 9) - #Laplacian : return [retval,dst] - edge = cv2.Laplacian(median_blur, cv2.CV_8U, 5) - #threshold mask : return [retval,dst] - mask = cv2.threshold(edge, 8, 255, cv2.THRESH_BINARY_INV) - #show the image - cv2.imshow('video capture test', mask[1]) - #char keypress = cv2.waitKey(20) - if cv2.waitKey(10) == 27: - break \ No newline at end of file diff --git a/OPENCV/ImageData/avatar.jpg b/OPENCV/ImageData/avatar.jpg deleted file mode 100644 index 1226ac7..0000000 Binary files a/OPENCV/ImageData/avatar.jpg and /dev/null differ diff --git a/OPENCV/ImageData/newImage.jpg b/OPENCV/ImageData/newImage.jpg deleted file mode 100644 index 20325b9..0000000 Binary files a/OPENCV/ImageData/newImage.jpg and /dev/null differ diff --git a/OPENCV/ImageData/output/random_color.png b/OPENCV/ImageData/output/random_color.png deleted file mode 100644 index 6f85543..0000000 Binary files a/OPENCV/ImageData/output/random_color.png and /dev/null differ diff --git a/OPENCV/ImageData/output/random_gray.png b/OPENCV/ImageData/output/random_gray.png deleted file mode 100644 index ada42be..0000000 Binary files a/OPENCV/ImageData/output/random_gray.png and /dev/null differ diff --git a/OPENCV/ImageData/test.jpg b/OPENCV/ImageData/test.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/OPENCV/ImageData/test.jpg and /dev/null differ diff --git a/OPENCV/ProgrammingCVwithPy/chapter01/ArrayImageRepresentation.py b/OPENCV/ProgrammingCVwithPy/chapter01/ArrayImageRepresentation.py deleted file mode 100644 index 83ad975..0000000 --- a/OPENCV/ProgrammingCVwithPy/chapter01/ArrayImageRepresentation.py +++ /dev/null @@ -1,10 +0,0 @@ -from PIL import Image -import numpy as np - -with Image.open("./OPENCV/ImageData/test.jpg") as img: - im = np.array(img) - print(im.shape) - print(im.dtype) - im = np.array(img.convert('L')) - print(im.shape) - print(im.dtype) \ No newline at end of file diff --git a/OPENCV/ProgrammingCVwithPy/chapter01/GreyLevelTransformation.py b/OPENCV/ProgrammingCVwithPy/chapter01/GreyLevelTransformation.py deleted file mode 100644 index e08a198..0000000 --- a/OPENCV/ProgrammingCVwithPy/chapter01/GreyLevelTransformation.py +++ /dev/null @@ -1,30 +0,0 @@ -from PIL import Image -import numpy as np -import matplotlib.pyplot as plt - -with Image.open("./OPENCV/ImageData/test.jpg") as img: - im = np.array(img.convert('L')) - img1 = Image.fromarray(im) - im = 255 - im - img2 = Image.fromarray(im) - im = (100.0/255)*im+100 - img3 = Image.fromarray(im) - im = 255*(im/255.0)**2 - img4 = Image.fromarray(im) - # print("im min :" ,im.min() , "max :" , im.max()) - plt.subplot(151) - plt.imshow(img) - plt.title("origin image") - plt.subplot(152) - plt.imshow(img1) - plt.title("inverse image") - plt.subplot(153) - plt.imshow(img2) - plt.title("inverse image") - plt.subplot(154) - plt.imshow(img3) - plt.title("inverse image") - plt.subplot(155) - plt.imshow(img4) - plt.title("inverse image") - plt.show() \ No newline at end of file diff --git a/OPENCV/ProgrammingCVwithPy/chapter01/ImageResize.py b/OPENCV/ProgrammingCVwithPy/chapter01/ImageResize.py deleted file mode 100644 index bf35f97..0000000 --- a/OPENCV/ProgrammingCVwithPy/chapter01/ImageResize.py +++ /dev/null @@ -1,7 +0,0 @@ -from PIL import Image -import numpy as np -import matplotlib.pyplot as plt - -def im_resize(img_array,size): - pil_img = Image.fromarray(uint8(img_array)) - return np.array(pil_img.resize(size)) \ No newline at end of file diff --git a/OPENCV/ProgrammingCVwithPy/chapter01/ReadImage.py b/OPENCV/ProgrammingCVwithPy/chapter01/ReadImage.py deleted file mode 100644 index f705a5b..0000000 --- a/OPENCV/ProgrammingCVwithPy/chapter01/ReadImage.py +++ /dev/null @@ -1,16 +0,0 @@ -import cv2 -from PIL import Image -import matplotlib.pyplot as plt - -pil_img = Image.open("./OPENCV/ImageData/test.jpg") -pil_img_L = pil_img.convert('L') - - -# cv2.imshow("Read Image",pil_img) -plt.subplot(121) -plt.imshow(pil_img) -plt.title("origin image") -plt.subplot(122) -plt.imshow(pil_img_L) -plt.title("gray scale image") -plt.show() \ No newline at end of file diff --git a/OPENCV/SURF.py b/OPENCV/SURF.py deleted file mode 100755 index 36c1953..0000000 --- a/OPENCV/SURF.py +++ /dev/null @@ -1,46 +0,0 @@ -import cv2 -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np - -im = cv2.imread("./OPENCV/bookexampleimg.png",1) -plt_originim = Image.open("./OPENCV/bookexampleimg.png") -#get the image width and height -h,w = im.shape[:2] -#down sampler -im_lower = cv2.pyrDown(im) -#gray image -gray = cv2.cvtColor(im_lower,cv2.COLOR_RGB2GRAY) -#detection the feature point -#s = cv2.SURF(400) -surf = cv2._getRawKeypoints() -mask = np.uint8(np.ones(gray.shape)) -keypoints = surf.detect(gray,mask) -#show the key points -vis = cv2.cvtColor(gray,cv2.COLOR_GRAY2BGR) - -for k in keypoints[::10]: - cv2.Circle(vis,(int(k.pt[0]),int(k.pt[1]),2,(0,255,0),-1)) - cv2.Circle(vis,(int(k.pt[0]),int(k.pt[1]),int(k.size),(0,255,0),2)) - -"""使用pyplot显示对比图像""" - -plt_im = cv2.cvtColor(vis,cv2.COLOR_BGR2RGB) -plt_originim = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -plt.subplot(121) -plt.imshow(plt_im) -plt.subplot(122) -plt.imshow(plt_originim) -plt.show() - - -#write the result into a jpg image file -cv2.imwrite("./OPENCV/floodfill result.jpg",vis) - -#cv2 image show -while True: - cv2.imshow("the flood fill image",vis) - if cv2.waitKey(10) == 27: - break - - diff --git a/OPENCV/VideoCapture01.py b/OPENCV/VideoCapture01.py deleted file mode 100755 index 8a06d58..0000000 --- a/OPENCV/VideoCapture01.py +++ /dev/null @@ -1,12 +0,0 @@ -import cv2 - -# setup video capture -cap = cv2.VideoCapture(0) - -# get frame, apply Gaussian smoothing, show result -while True: - ret,im = cap.read() - blur = cv2.GaussianBlur(im,(0,0),5) - cv2.imshow('camera blur',blur) - if cv2.waitKey(10) == 27: - break \ No newline at end of file diff --git a/OPENCV/VideoFrames.py b/OPENCV/VideoFrames.py deleted file mode 100755 index 95e0a89..0000000 --- a/OPENCV/VideoFrames.py +++ /dev/null @@ -1,17 +0,0 @@ -import cv2 -import numpy as np - -cap = cv2.VideoCapture(0) - -frames = [] -while True: - ret, im = cap.read() - cv2.imshow('video capture',im) - frames.append(im) - if cv2.waitKey(10) == 27: - break - -frames = np.array(frames) -print im.shape -print frames.shape - \ No newline at end of file diff --git a/OPENCV/bookexampleimg.png b/OPENCV/bookexampleimg.png deleted file mode 100755 index 259bf88..0000000 Binary files a/OPENCV/bookexampleimg.png and /dev/null differ diff --git a/OPENCV/floodfill result.jpg b/OPENCV/floodfill result.jpg deleted file mode 100755 index b33ed94..0000000 Binary files a/OPENCV/floodfill result.jpg and /dev/null differ diff --git a/OPENCV/floodfillImage.py b/OPENCV/floodfillImage.py deleted file mode 100755 index f030a44..0000000 --- a/OPENCV/floodfillImage.py +++ /dev/null @@ -1,34 +0,0 @@ -import cv2 -from PIL import Image -import matplotlib.pyplot as plt -import numpy as np - -im = cv2.imread("./OPENCV/bookexampleimg.png",1) -plt_originim = Image.open("./OPENCV/bookexampleimg.png") -#get the image width and height -h,w = im.shape[:2] - -#flood fill example -diff = (6,6,6) -mask = np.zeros((h+2,w+2),np.uint8) -floodfill = cv2.floodFill(im,mask,(10,10),(255,255,0),diff,diff) - -"""使用pyplot显示对比图像""" -plt_im = cv2.cvtColor(floodfill[1],cv2.COLOR_BGR2RGB) -im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) -plt.subplot(121) -plt.imshow(plt_im) -plt.subplot(122) -plt.imshow(plt_originim) -plt.show() - -#write the result into a jpg image file -cv2.imwrite("./OPENCV/floodfill result.jpg",floodfill[1]) - -#cv2 image show -while True: - cv2.imshow("the flood fill image",floodfill[1]) - if cv2.waitKey(10) == 27: - break - - diff --git a/OPENCV/integralimage.py b/OPENCV/integralimage.py deleted file mode 100755 index d1727f1..0000000 --- a/OPENCV/integralimage.py +++ /dev/null @@ -1,28 +0,0 @@ -#modules imports -import cv2 -from PIL import Image -import matplotlib.pylab as plt -import numpy as np - -#read the image -im = cv2.imread('./test.jpg') -gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) - -#calculate integral image -intim = cv2.integral(gray) - -#norm and save the image -normim = 255.0*intim/intim.max() -cv2.imwrite('integralresult.jpg',normim) - -im1 = Image.open('./test.jpg') -im2 = np.array(Image.open('./integralresult.jpg').convert('L')) -m,n = im2.shape[0:2] - -plt.figure() -ax = plt.subplot(121) -plt.imshow(im1) -plt.subplot(122) -plt.imshow(im2.reshape(m,-1)) - -plt.show() \ No newline at end of file diff --git a/OPENCV/lktrack.py b/OPENCV/lktrack.py deleted file mode 100755 index 00dc44a..0000000 --- a/OPENCV/lktrack.py +++ /dev/null @@ -1,55 +0,0 @@ -import cv2 -import numpy as np - - #useful default parameters -lk_params = dict(winSize=(15,15),maxLevel=2,criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT,10,0.03)) -subpix_params = dict(zeroZone=(-1,-1),winSize=(10,10),criteria = (cv2.TERM_CRITERIA_COUNT | cv2.TERM_CRITERIA_EPS,20,0.03)) -feature_params = dict(maxCorners=500,qualityLevel=0.01,minDistance=10) - -class LKTracker(object): - def __init__(self, imnames): - self.imnames = imnames - self.features = [] - self.tracks = [] - self.current_frame = 0 - self.image = None - self.prev_gray = self.gray = None - - def detect_points(self): - self.image = cv2.imread('./OPENCV/'+self.imnames[self.current_frame],1) - self.gray = cv2.cvtColor(self.image,cv2.COLOR_BGR2GRAY) - features = cv2.goodFeaturesToTrack(self.gray,**feature_params) - cv2.cornerSubPix(self.gray,features,**subpix_params) - self.features = features - self.tracks = [ [p] for p in features.reshape((-1,2)) ] - self.prev_gray = self.gray - - def track_points(self): - if self.features != []: - self.step() - self.image = cv2.imread('./OPENCV/'+self.imnames[self.current_frame],1) - self.gray = cv2.cvtColor(self.image,cv2.COLOR_BGR2GRAY) - tmp = np.float32(self.features).reshape(-1,1,2) - features,status,tracker_error = cv2.calcOpticalFlowPyrLK(self.prev_gray,self.gray,tmp,None,**lk_params) - self.features = [p for (st,p) in zip(status,features) if st] - features = np.array(features).reshape((-1,2)) - for i,f in enumerate(features): - self.tracks[i].append(f) - ndx = [i for (i,st) in enumerate(status) if not st] - ndx.reverse() - for i in ndx: - self.tracks.pop(i) - - self.prev_gray = self.gray - - def step(self,framenbr = None): - if framenbr is None: - self.current_frame = (self.current_frame + 1) % len(self.imnames) - else: - self.current_frame = framenbr % len(self.imnames) - - def draw(self): - for point in self.features: - cv2.circle(self.image, (int(point[0][0]),int(point[0][1])) ,3, (0,255,0),1) - cv2.imshow('LKtrack',self.image) - cv2.waitKey() \ No newline at end of file diff --git a/OPENCV/lktrack.pyc b/OPENCV/lktrack.pyc deleted file mode 100755 index 185d26b..0000000 Binary files a/OPENCV/lktrack.pyc and /dev/null differ diff --git a/OPENCV/lktracktest.py b/OPENCV/lktracktest.py deleted file mode 100755 index f1628c4..0000000 --- a/OPENCV/lktracktest.py +++ /dev/null @@ -1,18 +0,0 @@ -import lktrack -import cv2 - -imnames = ['test01.jpg','test02.jpg','test03.jpg','test04.jpg'] - -im = cv2.imread('./OPENCV/test.jpg',1) -for name in imnames: - cv2.imwrite('./OPENCV/'+name,im) - print name - -lkt = lktrack.LKTracker(imnames) - -lkt.detect_points() -#lkt.draw() -for i in range(len(imnames)-1): - lkt.track_points() - lkt.draw() - cv2.imwrite('./OPENCV/traked'+lkt.imnames[i],lkt.image[i]) \ No newline at end of file diff --git a/OPENCV/surftest.py b/OPENCV/surftest.py deleted file mode 100755 index 9fd918a..0000000 --- a/OPENCV/surftest.py +++ /dev/null @@ -1,55 +0,0 @@ -""" -Example of SURFTracker -""" -from SimpleCV import * -import cv - -def surftest(): - cam = Camera() - #img = cam.getImage() - ret,im = cam.read() - img = cv.CreateImage(ret,cv.IPL_DEPTH_8U,3) - d = Display(img.size()) - img, bb1 = getBBFromUser(cam,d) - fs1=[] - while True: - try: - img1 = cam.getImage() - fs1 = img1.track("surf",fs1,img,bb1, eps_val=0.8, dist=200, nframes=100) - fs1.drawBB(color=Color.RED) - fs1[-1].drawTrackerPoints() - print fs1[-1].getBB() - img1.show() - except KeyboardInterrupt: - break - -def getBBFromUser(cam, d): - p1 = None - p2 = None - img = cam.getImage() - while d.isNotDone(): - try: - img = cam.getImage() - img.save(d) - dwn = d.leftButtonDownPosition() - up = d.leftButtonUpPosition() - - if dwn: - p1 = dwn - if up: - p2 = up - break - - time.sleep(0.05) - except KeyboardInterrupt: - break - if not p1 or not p2: - return None - - xmax = np.max((p1[0],p2[0])) - xmin = np.min((p1[0],p2[0])) - ymax = np.max((p1[1],p2[1])) - ymin = np.min((p1[1],p2[1])) - return (img,(xmin,ymin,xmax-xmin,ymax-ymin)) - -surftest() \ No newline at end of file diff --git a/OPENCV/test.jpg b/OPENCV/test.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/OPENCV/test.jpg and /dev/null differ diff --git a/OPENCV/test01.jpg b/OPENCV/test01.jpg deleted file mode 100755 index b9edb00..0000000 Binary files a/OPENCV/test01.jpg and /dev/null differ diff --git a/OPENCV/test02.jpg b/OPENCV/test02.jpg deleted file mode 100755 index b9edb00..0000000 Binary files a/OPENCV/test02.jpg and /dev/null differ diff --git a/OPENCV/test03.jpg b/OPENCV/test03.jpg deleted file mode 100755 index b9edb00..0000000 Binary files a/OPENCV/test03.jpg and /dev/null differ diff --git a/OPENCV/test04.jpg b/OPENCV/test04.jpg deleted file mode 100755 index b9edb00..0000000 Binary files a/OPENCV/test04.jpg and /dev/null differ diff --git a/OPENCV/trakedtest01.jpg b/OPENCV/trakedtest01.jpg deleted file mode 100755 index 15300c2..0000000 Binary files a/OPENCV/trakedtest01.jpg and /dev/null differ diff --git a/OPENCV/trakedtest02.jpg b/OPENCV/trakedtest02.jpg deleted file mode 100755 index 4be5a1f..0000000 Binary files a/OPENCV/trakedtest02.jpg and /dev/null differ diff --git a/OPENCV/trakedtest03.jpg b/OPENCV/trakedtest03.jpg deleted file mode 100755 index 5fb91fa..0000000 Binary files a/OPENCV/trakedtest03.jpg and /dev/null differ diff --git a/Python_Code_Inprovement/chapter01/notes.md b/Python_Code_Inprovement/chapter01/notes.md new file mode 100644 index 0000000..42316f7 --- /dev/null +++ b/Python_Code_Inprovement/chapter01/notes.md @@ -0,0 +1,86 @@ +# 引论 + +## pythonic conception + +definition,code style,standard library,library or framework + +>> * 美胜丑 | 显胜隐 | 简胜杂 | 杂胜乱 | 平胜陡 | 疏胜密 +>> * 简单问题的一个方法也是唯一方法 +>> * 好主意易于解释 + + --- Zen Of Python +``` python +a = 1 , b = 2 +# not good +temp = a +a = b +b = temp +# good +a , b = b , a +``` +>> * 包和框架的名字用小写以及单数形式,并且短小 +>> * 包通常只作为命名空间 + +## pythonic coding + +### 避免劣化代码 + +>> * 避免只用大小写区分不同对象 +>> * 避免使用容易混淆的名字 +>> * 不要害怕过长的变量名 + +### 深入理解python + +>> * 语言特性和库特性 Official Languange Reference and Library Reference +>> * 知识更行(版本差异) +>> * Pythonic的框架 Flask gevent request + +## python与C语言的不同 + +>> * 代码缩进和{} + +>> * ' 和 " + +>> * 三元操作符 + + C风格 ———— ? : + Python风格 ———— X if conditions else statement + +>> * switch语句 + +``` c +switch(){ + case : + break; + case : + break; + default: + break; +} +``` + +```python +if : +elif : +elif : +else : +# 或者 +def f(x): + return { + 0: "you typed zero!", + 1: "you are in top!", + 2: "n is an even-number!", + }.get(x,"Only single-digital numbers are allowed.\n") + +``` + +## 代码中添加适当注释 + +## 函数四原则 +> * 短小,嵌套不宜过深 +> * 函数声明合理 简单 和易用 +> * 考虑向下兼容 +> * 函数语句粒度的一致性(一个函数只做一件事情) + +## 将常量集中在一个文件中 + diff --git a/Python_Code_Inprovement/chapter01/test.py b/Python_Code_Inprovement/chapter01/test.py new file mode 100644 index 0000000..c46134e --- /dev/null +++ b/Python_Code_Inprovement/chapter01/test.py @@ -0,0 +1,8 @@ +def f(x): + return { + 0: "you typed zero!", + 1: "you are in top!", + 2: "n is an even-number!" + }.get(x,"Only single-digital numbers are allowed.\n") + +print(f(5)) \ No newline at end of file diff --git a/Python_Code_Inprovement/chapter02/notes.md b/Python_Code_Inprovement/chapter02/notes.md new file mode 100644 index 0000000..9be929f --- /dev/null +++ b/Python_Code_Inprovement/chapter02/notes.md @@ -0,0 +1,5 @@ +# 编程惯用法 + +## 利用assert断言来发现问题 + +## \ No newline at end of file diff --git a/build/tk/Development/config.cache b/build/tk/Development/config.cache deleted file mode 100755 index e69de29..0000000 diff --git a/build/tk/Development/config.log b/build/tk/Development/config.log deleted file mode 100755 index 03ed3b9..0000000 --- a/build/tk/Development/config.log +++ /dev/null @@ -1,226 +0,0 @@ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by tk configure 8.6, which was -generated by GNU Autoconf 2.59. Invocation command line was - - $ /Users/nodegetout/Desktop/CodingProjects/PythonProj/tk8.6.6/macosx/../unix/configure -C --prefix=/usr/local --bindir=/usr/local/bin --libdir=/Library/Frameworks --mandir=/usr/local/man --enable-threads --enable-framework --with-tcl=/Library/Frameworks/Tcl.framework --enable-symbols --enable-aqua - -## --------- ## -## Platform. ## -## --------- ## - -hostname = bogon -uname -m = x86_64 -uname -r = 16.6.0 -uname -s = Darwin -uname -v = Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 - -/usr/bin/uname -p = i386 -/bin/uname -X = unknown - -/bin/arch = unknown -/usr/bin/arch -k = unknown -/usr/convex/getsysinfo = unknown -hostinfo = Mach kernel version: - Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 -Kernel configured for up to 8 processors. -4 processors are physically available. -8 processors are logically available. -Processor type: x86_64h (Intel x86-64h Haswell) -Processors active: 0 1 2 3 4 5 6 7 -Primary memory available: 16.00 gigabytes -Default processor set: 416 tasks, 1741 threads, 8 processors -Load average: 1.82, Mach factor: 6.16 -/bin/machine = unknown -/usr/bin/oslevel = unknown -/bin/universe = unknown - -PATH: /opt/local/bin -PATH: /opt/local/sbin -PATH: /Library/Frameworks/Python.framework/Versions/2.7/bin -PATH: /Users/nodegetout/.pyenv/shims -PATH: /Users/nodegetout/.pyenv/bin -PATH: /usr/local/bin -PATH: /usr/bin -PATH: /bin -PATH: /usr/sbin -PATH: /sbin -PATH: /usr/local/share/dotnet - - -## ----------- ## -## Core tests. ## -## ----------- ## - -configure:1238: loading cache config.cache -configure:1365: checking for Tcl configuration -configure:1385: error: /Library/Frameworks/Tcl.framework directory doesn't contain tclConfig.sh - -## ---------------- ## -## Cache variables. ## -## ---------------- ## - -ac_cv_env_CC_set= -ac_cv_env_CC_value= -ac_cv_env_CFLAGS_set= -ac_cv_env_CFLAGS_value= -ac_cv_env_CPPFLAGS_set= -ac_cv_env_CPPFLAGS_value= -ac_cv_env_CPP_set= -ac_cv_env_CPP_value= -ac_cv_env_LDFLAGS_set= -ac_cv_env_LDFLAGS_value= -ac_cv_env_build_alias_set= -ac_cv_env_build_alias_value= -ac_cv_env_host_alias_set= -ac_cv_env_host_alias_value= -ac_cv_env_target_alias_set= -ac_cv_env_target_alias_value= - -## ----------------- ## -## Output variables. ## -## ----------------- ## - -APP_RSRC_FILE='' -AR='' -BUILD_TCLSH='' -CC='' -CC_SEARCH_FLAGS='' -CFBUNDLELOCALIZATIONS='' -CFLAGS='' -CFLAGS_DEBUG='' -CFLAGS_DEFAULT='' -CFLAGS_OPTIMIZE='' -CFLAGS_WARNING='' -CPP='' -CPPFLAGS='' -DEFS='' -DLL_INSTALL_DIR='' -DL_LIBS='' -DL_OBJS='' -ECHO_C='ECHO_N='' -ECHO_T='' -EGREP='' -EXEEXT='' -EXTRA_APP_CC_SWITCHES='' -EXTRA_BUILD_HTML='' -EXTRA_CC_SWITCHES='' -EXTRA_INSTALL='' -EXTRA_INSTALL_BINARIES='' -EXTRA_WISH_LIBS='' -HTML_DIR='' -INSTALL_LIB='' -INSTALL_STUB_LIB='' -LDAIX_SRC='' -LDFLAGS='' -LDFLAGS_DEBUG='' -LDFLAGS_DEFAULT='' -LDFLAGS_OPTIMIZE='' -LD_LIBRARY_PATH_VAR='' -LD_SEARCH_FLAGS='' -LIBOBJS='' -LIBS='' -LIB_RSRC_FILE='' -LIB_RUNTIME_DIR='' -LOCALES='cs da de el en en_gb eo es fr hu it nl pl pt ru sv' -LTLIBOBJS='' -MAKE_LIB='' -MAKE_STUB_LIB='' -MAN_FLAGS='' -OBJEXT='' -PACKAGE_BUGREPORT='' -PACKAGE_NAME='tk' -PACKAGE_STRING='tk 8.6' -PACKAGE_TARNAME='tk' -PACKAGE_VERSION='8.6' -PATH_SEPARATOR=':' -PLAT_OBJS='' -PLAT_SRCS='' -PRIVATE_INCLUDE_DIR='' -RANLIB='' -REZ='' -REZ_FLAGS='' -SHELL='/bin/sh' -SHLIB_CFLAGS='' -SHLIB_LD='' -SHLIB_LD_LIBS='' -SHLIB_SUFFIX='' -STLIB_LD='' -TCLSH_PROG='' -TCL_BIN_DIR='' -TCL_LIBS='' -TCL_LIB_FILE='' -TCL_LIB_FLAG='' -TCL_LIB_SPEC='' -TCL_PATCH_LEVEL='' -TCL_SHLIB_LD_EXTRAS='' -TCL_SRC_DIR='' -TCL_STUB_FLAGS='' -TCL_STUB_LIB_FILE='' -TCL_STUB_LIB_FLAG='' -TCL_STUB_LIB_SPEC='' -TCL_THREADS='' -TCL_VERSION='' -TK_BUILD_LIB_SPEC='' -TK_BUILD_STUB_LIB_PATH='' -TK_BUILD_STUB_LIB_SPEC='' -TK_INCLUDE_SPEC='' -TK_LIBRARY='' -TK_LIB_FILE='' -TK_LIB_FLAG='' -TK_LIB_SPEC='' -TK_MAJOR_VERSION='8' -TK_MINOR_VERSION='6' -TK_PATCH_LEVEL='.6' -TK_PKG_DIR='' -TK_RSRC_FILE='' -TK_SHARED_BUILD='' -TK_SHLIB_LD_EXTRAS='' -TK_SRC_DIR='' -TK_STUB_LIB_FILE='' -TK_STUB_LIB_FLAG='' -TK_STUB_LIB_PATH='' -TK_STUB_LIB_SPEC='' -TK_VERSION='8.6' -TK_WINDOWINGSYSTEM='' -TK_YEAR='' -UNIX_FONT_OBJS='' -WISH_RSRC_FILE='' -XFT_CFLAGS='' -XFT_LIBS='' -XINCLUDES='' -XLIBSW='' -ac_ct_AR='' -ac_ct_CC='' -ac_ct_RANLIB='' -bindir='/usr/local/bin' -build_alias='' -datadir='${prefix}/share' -exec_prefix='NONE' -host_alias='' -includedir='${prefix}/include' -infodir='${prefix}/info' -libdir='/Library/Frameworks' -libexecdir='${exec_prefix}/libexec' -localstatedir='${prefix}/var' -mandir='/usr/local/man' -oldincludedir='/usr/include' -prefix='/usr/local' -program_transform_name='s,x,x,' -sbindir='${exec_prefix}/sbin' -sharedstatedir='${prefix}/com' -sysconfdir='${prefix}/etc' -target_alias='' - -## ----------- ## -## confdefs.h. ## -## ----------- ## - -#define PACKAGE_BUGREPORT "" -#define PACKAGE_NAME "tk" -#define PACKAGE_STRING "tk 8.6" -#define PACKAGE_TARNAME "tk" -#define PACKAGE_VERSION "8.6" - -configure: exit 1 diff --git a/code/alg/find_remove_find1.py b/code/alg/find_remove_find1.py deleted file mode 100755 index 2765e2e..0000000 --- a/code/alg/find_remove_find1.py +++ /dev/null @@ -1,7 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - find the index of the minimum element in L - remove that element from the list - find the index of the new minimum element in the list - return the two indices diff --git a/code/alg/find_remove_find2.py b/code/alg/find_remove_find2.py deleted file mode 100755 index 0c1cdb3..0000000 --- a/code/alg/find_remove_find2.py +++ /dev/null @@ -1,8 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - get the minimum element in L - find the index of that minimum element - remove that element from the list - find the index of the new minimum element in the list - return the two indices diff --git a/code/alg/find_remove_find3.py b/code/alg/find_remove_find3.py deleted file mode 100755 index 2d27efa..0000000 --- a/code/alg/find_remove_find3.py +++ /dev/null @@ -1,10 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - smallest = min(L) - min1 = L.index(smallest) - L.remove(smallest) - next_smallest = min(L) - min2 = L.index(next_smallest) - - return the two indices diff --git a/code/alg/find_remove_find4.py b/code/alg/find_remove_find4.py deleted file mode 100755 index 8e04cef..0000000 --- a/code/alg/find_remove_find4.py +++ /dev/null @@ -1,12 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - smallest = min(L) - min1 = L.index(smallest) - L.remove(smallest) - next_smallest = min(L) - min2 = L.index(next_smallest) - - put smallest back into L - if min1 comes before min2, add 1 to min2 - return the two indices diff --git a/code/alg/find_remove_find5.py b/code/alg/find_remove_find5.py deleted file mode 100755 index 0c8bb7a..0000000 --- a/code/alg/find_remove_find5.py +++ /dev/null @@ -1,14 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - smallest = min(L) - min1 = L.index(smallest) - L.remove(smallest) - next_smallest = min(L) - min2 = L.index(next_smallest) - - L.insert(min1, smallest) - if min1 <= min2: - min2 += 1 - - return (min1, min2) diff --git a/code/alg/search1.cmd b/code/alg/search1.cmd deleted file mode 100755 index e5ca9ed..0000000 --- a/code/alg/search1.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> counts = [809, 834, 477, 478, 307, 122, 96, 102, 324, 476] ->>> min(counts) -96 diff --git a/code/alg/search2.cmd b/code/alg/search2.cmd deleted file mode 100755 index c40c980..0000000 --- a/code/alg/search2.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> counts = [809, 834, 477, 478, 307, 122, 96, 102, 324, 476] ->>> low = min(counts) ->>> min_index = counts.index(low) ->>> print min_index -6 diff --git a/code/alg/search3.cmd b/code/alg/search3.cmd deleted file mode 100755 index 290178e..0000000 --- a/code/alg/search3.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> counts = [809, 834, 477, 478, 307, 122, 96, 102, 324, 476] ->>> counts.index(min(counts)) -6 diff --git a/code/alg/sort_then_find1.py b/code/alg/sort_then_find1.py deleted file mode 100755 index 0e2f273..0000000 --- a/code/alg/sort_then_find1.py +++ /dev/null @@ -1,6 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - sort a copy of L - get the two smallest numbers - find their indices in the original list L - return the two indices diff --git a/code/alg/sort_then_find2.py b/code/alg/sort_then_find2.py deleted file mode 100755 index b1a6b9a..0000000 --- a/code/alg/sort_then_find2.py +++ /dev/null @@ -1,9 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - temp_list = L[:] - temp_list.sort() - smallest = temp_list[0] - next_smallest = temp_list[1] - find their indices in the original list - return the two indices diff --git a/code/alg/sort_then_find3.py b/code/alg/sort_then_find3.py deleted file mode 100755 index 7caaab1..0000000 --- a/code/alg/sort_then_find3.py +++ /dev/null @@ -1,10 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - temp_list = L[:] - temp_list.sort() - smallest = temp_list[0] - next_smallest = temp_list[1] - min1 = L.index(smallest) - min2 = L.index(next_smallest) - return (min1, min2) diff --git a/code/alg/walk_through1.py b/code/alg/walk_through1.py deleted file mode 100755 index 914d59f..0000000 --- a/code/alg/walk_through1.py +++ /dev/null @@ -1,7 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - examine each value in the list in order - keep track of the indices of the two smallest values found so far - update these values when a new smaller value is found - return the two indices diff --git a/code/alg/walk_through2.py b/code/alg/walk_through2.py deleted file mode 100755 index 4df112b..0000000 --- a/code/alg/walk_through2.py +++ /dev/null @@ -1,7 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - keep track of the indices of the two smallest values found so far - examine each value in the list in order - update these values when a new smaller value is found - return the two indices diff --git a/code/alg/walk_through3.py b/code/alg/walk_through3.py deleted file mode 100755 index 9ae7645..0000000 --- a/code/alg/walk_through3.py +++ /dev/null @@ -1,9 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - set min1 and min2 to the indices of the smallest and next-smallest - values at the beginning of L - - examine each value in the list in order - update these values when a new smaller value is found - return the two indices diff --git a/code/alg/walk_through4.py b/code/alg/walk_through4.py deleted file mode 100755 index 76217bd..0000000 --- a/code/alg/walk_through4.py +++ /dev/null @@ -1,13 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - # set min1 and min2 to the indices of the smallest and next-smallest - # values at the beginning of L - if L[0] < L[1]: - smallest, next_smallest = 0, 1 - else: - smallest, next_smallest = 1, 0 - - examine each value in the list in order - update these values when a new smaller value is found - return the two indices diff --git a/code/alg/walk_through5.py b/code/alg/walk_through5.py deleted file mode 100755 index 140253e..0000000 --- a/code/alg/walk_through5.py +++ /dev/null @@ -1,14 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - # set min1 and min2 to the indices of the smallest and next-smallest - # values at the beginning of L - if L[0] < L[1]: - min1, min2 = 0, 1 - else: - min2, min1 = 0, 1 - - # examine each value in the list in order - for i in range(2, len(values)): - update min1 and/or min2 when a new smaller value is found - return the two indices diff --git a/code/alg/walk_through6.py b/code/alg/walk_through6.py deleted file mode 100755 index f1f81df..0000000 --- a/code/alg/walk_through6.py +++ /dev/null @@ -1,20 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - - # set min1 and min2 to the indices of the smallest and next-smallest - # values at the beginning of L - if L[0] < L[1]: - min1, min2 = 0, 1 - else: - min2, min1 = 1, 0 - - # examine each value in the list in order - for i in range(2, len(L)): - - L[i] is larger than both min1 and min2, smaller than both, or - in between. - if L[i] is larger than both min1 and min2, skip it - if L[i] is smaller than min1 and min2, update them both - if L[i] is in between, update min2 - - return (min1, min2) diff --git a/code/alg/walk_through7.py b/code/alg/walk_through7.py deleted file mode 100755 index c03f69e..0000000 --- a/code/alg/walk_through7.py +++ /dev/null @@ -1,20 +0,0 @@ -def find_two_smallest(L): - '''Return a tuple of the indices of the two smallest values in list L.''' - # set min1 and min2 to the indices of the smallest and next-smallest - # values at the beginning of L - if L[0] < L[1]: - min1, min2 = 0, 1 - else: - min2, min1 = 1, 0 - # examine each value in the list in order - for i in range(2, len(L)): - # L[i] is larger than both min1 and min2, smaller than both, or - # in between. - # New smallest? - if L[i] < L[min1]: - min2 = min1 - min1 = i - # New second smallest? - elif L[i] < L[min2]: - min2 = i - return (min1, min2) diff --git a/code/basic/abs.cmd b/code/basic/abs.cmd deleted file mode 100755 index 896495d..0000000 --- a/code/basic/abs.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> abs(-9) -9 diff --git a/code/basic/addition.cmd b/code/basic/addition.cmd deleted file mode 100755 index 1273c23..0000000 --- a/code/basic/addition.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 4 + 13 -17 diff --git a/code/basic/assignment.cmd b/code/basic/assignment.cmd deleted file mode 100755 index 3c8b359..0000000 --- a/code/basic/assignment.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> degrees_celsius = 26.0 diff --git a/code/basic/assignment2.cmd b/code/basic/assignment2.cmd deleted file mode 100755 index 9ddfe53..0000000 --- a/code/basic/assignment2.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> difference = 100 - degrees_celsius diff --git a/code/basic/fahr_to_cel.cmd b/code/basic/fahr_to_cel.cmd deleted file mode 100755 index ab08ef7..0000000 --- a/code/basic/fahr_to_cel.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> def to_celsius(t): -... return (t - 32.0) * 5.0 / 9.0 -... diff --git a/code/basic/fahr_to_cel_2.cmd b/code/basic/fahr_to_cel_2.cmd deleted file mode 100755 index 41139b9..0000000 --- a/code/basic/fahr_to_cel_2.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> to_celsius(80) -26.666666666666668 ->>> to_celsius(78.8) -26.0 ->>> to_celsius(10.4) --12.0 diff --git a/code/basic/float_div_intro.cmd b/code/basic/float_div_intro.cmd deleted file mode 100755 index cafc7bd..0000000 --- a/code/basic/float_div_intro.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 17.0 / 10.0 -1.7 diff --git a/code/basic/float_division.cmd b/code/basic/float_division.cmd deleted file mode 100755 index 660431d..0000000 --- a/code/basic/float_division.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 17.0 / 10 -1.7 ->>> 17 / 10.0 -1.7 diff --git a/code/basic/float_division2.cmd b/code/basic/float_division2.cmd deleted file mode 100755 index ddd6ada..0000000 --- a/code/basic/float_division2.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 17 / 10. -1.7 ->>> 17. / 10 -1.7 diff --git a/code/basic/int_div.cmd b/code/basic/int_div.cmd deleted file mode 100755 index eb9fdeb..0000000 --- a/code/basic/int_div.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 17 / 10 -1 diff --git a/code/basic/int_mod.cmd b/code/basic/int_mod.cmd deleted file mode 100755 index 03ceee1..0000000 --- a/code/basic/int_mod.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 17 % 10 -7 diff --git a/code/basic/local_variable.cmd b/code/basic/local_variable.cmd deleted file mode 100755 index e552b21..0000000 --- a/code/basic/local_variable.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> polynomial(2, 3, 4, 1.3) -11.280000000000001 ->>> first -Traceback (most recent call last): - File "", line 1, in -NameError: name 'first' is not defined ->>> a -Traceback (most recent call last): - File "", line 1, in -NameError: name 'a' is not defined diff --git a/code/basic/matching_args_params.cmd b/code/basic/matching_args_params.cmd deleted file mode 100755 index 6f1a686..0000000 --- a/code/basic/matching_args_params.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> polynomial(1, 2, 3) -Traceback (most recent call last): - File "", line 1, in -TypeError: polynomial() takes exactly 4 arguments (3 given) diff --git a/code/basic/multi_statement_block.cmd b/code/basic/multi_statement_block.cmd deleted file mode 100755 index 3798950..0000000 --- a/code/basic/multi_statement_block.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> def polynomial(a, b, c, x): -... first = a * x * x -... second = b * x -... third = c -... return first + second + third -... ->>> polynomial(2, 3, 4, 0.5) -6.0 ->>> polynomial(2, 3, 4, 1.5) -13.0 diff --git a/code/basic/neg_int_div.cmd b/code/basic/neg_int_div.cmd deleted file mode 100755 index 8f43e28..0000000 --- a/code/basic/neg_int_div.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> -17 / 10 --2 \ No newline at end of file diff --git a/code/basic/neg_int_mod.cmd b/code/basic/neg_int_mod.cmd deleted file mode 100755 index 23ccde2..0000000 --- a/code/basic/neg_int_mod.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> -17 % 10 -3 ->>> 17 % -10 --3 \ No newline at end of file diff --git a/code/basic/precedence.cmd b/code/basic/precedence.cmd deleted file mode 100755 index fc843f4..0000000 --- a/code/basic/precedence.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 212 - 32.0 * 5.0 / 9.0 -194.22222222222223 \ No newline at end of file diff --git a/code/basic/precedence_diff.cmd b/code/basic/precedence_diff.cmd deleted file mode 100755 index 86513d5..0000000 --- a/code/basic/precedence_diff.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> (212 - 32.0) * 5.0 / 9.0 -100.0 \ No newline at end of file diff --git a/code/basic/rate.cmd b/code/basic/rate.cmd deleted file mode 100755 index 8dd9aaf..0000000 --- a/code/basic/rate.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 1.0 / 3.0 -0.33333333333333331 diff --git a/code/basic/round.cmd b/code/basic/round.cmd deleted file mode 100755 index 568b62e..0000000 --- a/code/basic/round.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> round(3.8) -4.0 ->>> round(3.3) -3.0 ->>> round(3.5) -4.0 diff --git a/code/basic/simplevalue.cmd b/code/basic/simplevalue.cmd deleted file mode 100755 index d085946..0000000 --- a/code/basic/simplevalue.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 3 -3 diff --git a/code/basic/syntax_error.cmd b/code/basic/syntax_error.cmd deleted file mode 100755 index 32add33..0000000 --- a/code/basic/syntax_error.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> 2 + - File "", line 1 - 2 + - ^ -SyntaxError: invalid syntax diff --git a/code/basic/two_args.cmd b/code/basic/two_args.cmd deleted file mode 100755 index 3c07b13..0000000 --- a/code/basic/two_args.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> pow(2, 4) -16 \ No newline at end of file diff --git a/code/basic/typeconvert.cmd b/code/basic/typeconvert.cmd deleted file mode 100755 index e1cd61c..0000000 --- a/code/basic/typeconvert.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> int(34.6) -34 ->>> float(21) -21.0 diff --git a/code/basic/undefined_var.cmd b/code/basic/undefined_var.cmd deleted file mode 100755 index c44c8be..0000000 --- a/code/basic/undefined_var.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 3 + something -Traceback (most recent call last): - File "", line 1, in -NameError: name 'something' is not defined diff --git a/code/basic/variable.cmd b/code/basic/variable.cmd deleted file mode 100755 index 5107ca4..0000000 --- a/code/basic/variable.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 100 - degrees_celsius -74.0 diff --git a/code/basic/variable2.cmd b/code/basic/variable2.cmd deleted file mode 100755 index ee4caa7..0000000 --- a/code/basic/variable2.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> difference -74.0 diff --git a/code/basic/variable3.cmd b/code/basic/variable3.cmd deleted file mode 100755 index d2cb886..0000000 --- a/code/basic/variable3.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> difference = 100 - 15.5 ->>> difference -84.5 diff --git a/code/basic/variable4.cmd b/code/basic/variable4.cmd deleted file mode 100755 index ded4a51..0000000 --- a/code/basic/variable4.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> difference = 20 ->>> double = 2 * difference ->>> double -40 ->>> difference = 5 ->>> double -40 diff --git a/code/basic/variable5.cmd b/code/basic/variable5.cmd deleted file mode 100755 index bb62b39..0000000 --- a/code/basic/variable5.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> number = 3 ->>> number -3 ->>> number = 2 * number ->>> number -6 ->>> number = number * number ->>> number -36 diff --git a/code/basic/variable6.cmd b/code/basic/variable6.cmd deleted file mode 100755 index af174a9..0000000 --- a/code/basic/variable6.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> number = 100 ->>> number -= 80 ->>> number -20 diff --git a/code/basic/variable7.cmd b/code/basic/variable7.cmd deleted file mode 100755 index 6e03224..0000000 --- a/code/basic/variable7.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> d = 2 ->>> d *= 3 + 4 ->>> d -14 diff --git a/code/basic/variable8.cmd b/code/basic/variable8.cmd deleted file mode 100755 index babbe88..0000000 --- a/code/basic/variable8.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> number = 10 ->>> number *= number ->>> number -100 diff --git a/code/basic/variable9.cmd b/code/basic/variable9.cmd deleted file mode 100755 index 8d0781b..0000000 --- a/code/basic/variable9.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> number = 10 ->>> number = number * number ->>> number -100 diff --git a/code/cond/acidity.cmd b/code/cond/acidity.cmd deleted file mode 100755 index b5c2ae7..0000000 --- a/code/cond/acidity.cmd +++ /dev/null @@ -1,5 +0,0 @@ -ph = float(raw_input("Enter the ph level: ")) -if ph < 7.0: - print "It's acidic!" -elif ph < 4.0: - print "It's a strong acid!" \ No newline at end of file diff --git a/code/cond/and.cmd b/code/cond/and.cmd deleted file mode 100755 index c7ce676..0000000 --- a/code/cond/and.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> 0 and 3 -0 ->>> 3 and 0 -0 ->>> 3 and 5 -5 diff --git a/code/cond/assign_bool.cmd b/code/cond/assign_bool.cmd deleted file mode 100755 index b852df0..0000000 --- a/code/cond/assign_bool.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> x = 15 > 5 diff --git a/code/cond/bool_math.cmd b/code/cond/bool_math.cmd deleted file mode 100755 index f86fe64..0000000 --- a/code/cond/bool_math.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 5 + True -6 ->>> 7 - False -7 diff --git a/code/cond/boolean_and_examples.cmd b/code/cond/boolean_and_examples.cmd deleted file mode 100755 index 6c81b48..0000000 --- a/code/cond/boolean_and_examples.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> True and True -True ->>> False and False -False ->>> True and False -False ->>> False and True -False diff --git a/code/cond/boolean_expression.cmd b/code/cond/boolean_expression.cmd deleted file mode 100755 index 4f04752..0000000 --- a/code/cond/boolean_expression.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> (not cold) and windy ->>> not (cold and windy) diff --git a/code/cond/boolean_not_examples.cmd b/code/cond/boolean_not_examples.cmd deleted file mode 100755 index 265c6b0..0000000 --- a/code/cond/boolean_not_examples.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> not True -False ->>> not False -True diff --git a/code/cond/boolean_or_examples.cmd b/code/cond/boolean_or_examples.cmd deleted file mode 100755 index a30f826..0000000 --- a/code/cond/boolean_or_examples.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> True or True -True ->>> False or False -False ->>> True or False -True ->>> False or True -True diff --git a/code/cond/chain1.cmd b/code/cond/chain1.cmd deleted file mode 100755 index 86cef4d..0000000 --- a/code/cond/chain1.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> x = 3 ->>> 1 < x <= 5 -True diff --git a/code/cond/chain2.cmd b/code/cond/chain2.cmd deleted file mode 100755 index c53849e..0000000 --- a/code/cond/chain2.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 3 < 5 != True -True ->>> 3 < 5 != False -True diff --git a/code/cond/compare_range.cmd b/code/cond/compare_range.cmd deleted file mode 100755 index a5e8e16..0000000 --- a/code/cond/compare_range.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> x = 3 ->>> (1 < x) and (x <= 5) -True ->>> x = 7 ->>> (1 < x) and (x <= 5) -False diff --git a/code/cond/div_zero.cmd b/code/cond/div_zero.cmd deleted file mode 100755 index eb0e54a..0000000 --- a/code/cond/div_zero.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 1 / 0 -Traceback (most recent call last): - File "", line 1, in -ZeroDivisionError: integer division or modulo by zero \ No newline at end of file diff --git a/code/cond/elif_basic.cmd b/code/cond/elif_basic.cmd deleted file mode 100755 index 55cc0eb..0000000 --- a/code/cond/elif_basic.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> ph = float(raw_input()) -8.5 ->>> if ph < 7.0: -... print "%s is acidic." % (ph) -... elif ph > 7.0: -... print "%s is basic." % (ph) -... -8.5 is basic. ->>> diff --git a/code/cond/elif_longer.cmd b/code/cond/elif_longer.cmd deleted file mode 100755 index 9a7f9c1..0000000 --- a/code/cond/elif_longer.cmd +++ /dev/null @@ -1,11 +0,0 @@ ->>> compound = raw_input() -CH3 ->>> if compound == "H2O": -... print "Water" -... elif compound == "NH3": -... print "Ammonia" -... elif compound == "CH4": -... print "Methane" -... -Methane ->>> diff --git a/code/cond/elif_wrongorder.cmd b/code/cond/elif_wrongorder.cmd deleted file mode 100755 index 6c04f59..0000000 --- a/code/cond/elif_wrongorder.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> if ph < 7.0: -... print "%s is acidic." % (ph) -... elif ph < 3.0: -... print "%s is VERY acidic! Be careful." % (ph) -... diff --git a/code/cond/else_basic.cmd b/code/cond/else_basic.cmd deleted file mode 100755 index c32e750..0000000 --- a/code/cond/else_basic.cmd +++ /dev/null @@ -1,13 +0,0 @@ ->>> compound = raw_input() -H2SO4 ->>> if compound == "H2O": -... print "Water" -... elif compound == "NH3": -... print "Ammonia" -... elif compound == "CH3": -... print "Methane" -... else: -... print "Unknown compound" -... -Unknown compound ->>> diff --git a/code/cond/empty_false.cmd b/code/cond/empty_false.cmd deleted file mode 100755 index 238cc54..0000000 --- a/code/cond/empty_false.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> '' and False -'' ->>> 'salmon' or True -'salmon' diff --git a/code/cond/if_basicfalse.cmd b/code/cond/if_basicfalse.cmd deleted file mode 100755 index a940e55..0000000 --- a/code/cond/if_basicfalse.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> ph = float(raw_input()) -8.0 ->>> if ph < 7.0: -... print "%s is acidic." % (ph) -... ->>> diff --git a/code/cond/if_basictrue.cmd b/code/cond/if_basictrue.cmd deleted file mode 100755 index c519e19..0000000 --- a/code/cond/if_basictrue.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> ph = float(raw_input()) -6.0 ->>> if ph < 7.0: -... print "%s is acidic." % (ph) -... -6.0 is acidic. diff --git a/code/cond/if_indenterror.cmd b/code/cond/if_indenterror.cmd deleted file mode 100755 index 9ba3b02..0000000 --- a/code/cond/if_indenterror.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> ph = float(raw_input()) -6.0 ->>> if ph < 7.0: -... print "%s is acidic." % (ph) - File "", line 2 - print "%s is acidic." % (ph) - ^ -IndentationError: expected an indented block \ No newline at end of file diff --git a/code/cond/if_multiline_indent_error.cmd b/code/cond/if_multiline_indent_error.cmd deleted file mode 100755 index 8fe3b9a..0000000 --- a/code/cond/if_multiline_indent_error.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> ph = float(raw_input()) -8.0 ->>> if ph < 7.0: -... print "%s is acidic." % (ph) -... ->>> print "You should be careful with that!" -You should be careful with that! \ No newline at end of file diff --git a/code/cond/if_multiline_indent_error2.cmd b/code/cond/if_multiline_indent_error2.cmd deleted file mode 100755 index ed04d4d..0000000 --- a/code/cond/if_multiline_indent_error2.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> ph = float(raw_input()) -8.0 ->>> if ph < 7.0: -... print "%s is acidic." % (ph) -... print "You should be careful with that!" - File "", line 3 - print "You should be careful with that!" - ^ -SyntaxError: invalid syntax \ No newline at end of file diff --git a/code/cond/if_multiline_indent_error3.cmd b/code/cond/if_multiline_indent_error3.cmd deleted file mode 100755 index 11133b8..0000000 --- a/code/cond/if_multiline_indent_error3.cmd +++ /dev/null @@ -1,4 +0,0 @@ -ph = 8.0 -if ph < 7.0: - print "%s is acidic." % (ph) -print "You should be careful with that!" diff --git a/code/cond/if_multilinetrue.cmd b/code/cond/if_multilinetrue.cmd deleted file mode 100755 index 949975f..0000000 --- a/code/cond/if_multilinetrue.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> ph = float(raw_input()) -6.0 ->>> if ph < 7.0: -... print "%s is acidic." % (ph) -... print "You should be careful with that!" -... -6.0 is acidic. -You should be careful with that! diff --git a/code/cond/multi_if.cmd b/code/cond/multi_if.cmd deleted file mode 100755 index afbdbf7..0000000 --- a/code/cond/multi_if.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> ph = float(raw_input()) -8.5 ->>> if ph < 7.0: -... print "%s is acidic." % (ph) -... ->>> if ph > 7.0: -... print "%s is basic." % (ph) -... -8.5 is basic. ->>> diff --git a/code/cond/nested_if.cmd b/code/cond/nested_if.cmd deleted file mode 100755 index f635bc5..0000000 --- a/code/cond/nested_if.cmd +++ /dev/null @@ -1,11 +0,0 @@ -input = raw_input() -if len(input) > 0: - ph = float(input) - if ph < 7.0: - print "%s is acidic." % (ph) - elif ph > 7.0: - print "%s is basic." % (ph) - else: - print "%s is neutral." % (ph) -else: - print "No pH value was given!" diff --git a/code/cond/nested_if_combined.cmd b/code/cond/nested_if_combined.cmd deleted file mode 100755 index 367d053..0000000 --- a/code/cond/nested_if_combined.cmd +++ /dev/null @@ -1,8 +0,0 @@ -if ph_reliable and ph < 7.0: - print "%s is acidic." % (ph) -elif ph_reliable and ph > 7.0: - print "%s is basic." % (ph) -elif ph_reliable: - print "%s is neutral." % (ph) -else: - print "That pH reading isn't reliable!" diff --git a/code/cond/not.cmd b/code/cond/not.cmd deleted file mode 100755 index 4a74e52..0000000 --- a/code/cond/not.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> not 0 -True ->>> not 1 -False ->>> not 5 -False ->>> not 34.2 -False ->>> not -87 -False diff --git a/code/cond/or.cmd b/code/cond/or.cmd deleted file mode 100755 index 09df973..0000000 --- a/code/cond/or.cmd +++ /dev/null @@ -1,12 +0,0 @@ ->>> 1 or 0 -1 ->>> 0 or 1 -1 ->>> True or 0 -True ->>> 0 or False -False ->>> False or 0 -0 ->>> False or 18.2 -18.199999999999999 diff --git a/code/cond/or_lazy.cmd b/code/cond/or_lazy.cmd deleted file mode 100755 index 217cfb6..0000000 --- a/code/cond/or_lazy.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> True or 1 / 0 -True \ No newline at end of file diff --git a/code/cond/parens_included.cmd b/code/cond/parens_included.cmd deleted file mode 100755 index de1ffdd..0000000 --- a/code/cond/parens_included.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> (x < y) and (y < z) -True diff --git a/code/cond/relational_1.cmd b/code/cond/relational_1.cmd deleted file mode 100755 index 17c65b3..0000000 --- a/code/cond/relational_1.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> 45 > 34 -True ->>> 45 > 79 -False ->>> 45 < 79 -True ->>> 45 < 34 -False \ No newline at end of file diff --git a/code/cond/relational_2.cmd b/code/cond/relational_2.cmd deleted file mode 100755 index 78f4311..0000000 --- a/code/cond/relational_2.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> 23.1 >= 23 -True ->>> 23.1 >= 23.1 -True ->>> 23.1 <= 23.1 -True ->>> 23.1 <= 23 -False diff --git a/code/cond/relational_3.cmd b/code/cond/relational_3.cmd deleted file mode 100755 index fb67e69..0000000 --- a/code/cond/relational_3.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> 67.3 == 87 -False ->>> 67.3 == 67 -False ->>> 67.0 == 67 -True ->>> 67.0 != 67 -False ->>> 67.0 != 23 -True \ No newline at end of file diff --git a/code/cond/relational_var.cmd b/code/cond/relational_var.cmd deleted file mode 100755 index 950a31d..0000000 --- a/code/cond/relational_var.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> def positive(x): -... return x > 0 -... ->>> positive(3) -True ->>> positive(-2) -False ->>> positive(0) -False diff --git a/code/cond/skipping_parens.cmd b/code/cond/skipping_parens.cmd deleted file mode 100755 index 4587ff8..0000000 --- a/code/cond/skipping_parens.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> x = 2 ->>> y = 5 ->>> z = 7 ->>> x < y and y < z -True diff --git a/code/cond/string_compare.cmd b/code/cond/string_compare.cmd deleted file mode 100755 index 67930ee..0000000 --- a/code/cond/string_compare.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> 'A' < 'a' -True ->>> 'A' > 'z' -False ->>> 'abc' < 'abd' -True ->>> 'abc' < 'abcd' -True diff --git a/code/cond/truefalse.cmd b/code/cond/truefalse.cmd deleted file mode 100755 index 22b4633..0000000 --- a/code/cond/truefalse.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> False == 0 -True ->>> True == 1 -True ->>> True == 2 -False ->>> False < True -True diff --git a/code/construct/add_error_handling.py b/code/construct/add_error_handling.py deleted file mode 100755 index a6951b9..0000000 --- a/code/construct/add_error_handling.py +++ /dev/null @@ -1,7 +0,0 @@ -def process_file(filename): - '''Read and print the contents of a file.''' - - f = open(filename, 'r') - for line in f: - line = line.strip() - print line diff --git a/code/construct/afterdate.py b/code/construct/afterdate.py deleted file mode 100755 index bd840dd..0000000 --- a/code/construct/afterdate.py +++ /dev/null @@ -1,10 +0,0 @@ -def after_date(input_file, date): - '''Return the lines that were added to a file after a certain date.''' - keep_it = False - result = [] - for line in input_file: - if keep_it: - result.append(line) - elif get_date(line) >= date: - keep_it = True - return result diff --git a/code/construct/append_all.cmd b/code/construct/append_all.cmd deleted file mode 100755 index 90b1e0b..0000000 --- a/code/construct/append_all.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> def append_all(old, *new): -... for n in new: -... old.append(n) -... return old -... ->>> values = [] ->>> append_all(values, 1, 2, 3) -[1, 2, 3] ->>> append_all(values) # not actually appending anything -[1, 2, 3] diff --git a/code/construct/compare_strings.py b/code/construct/compare_strings.py deleted file mode 100755 index f4eccef..0000000 --- a/code/construct/compare_strings.py +++ /dev/null @@ -1,4 +0,0 @@ -if my_compare('abc', 'def') == -1: - print 'success' -else: - print 'failure' diff --git a/code/construct/compare_strings_nose.py b/code/construct/compare_strings_nose.py deleted file mode 100755 index 4915f9f..0000000 --- a/code/construct/compare_strings_nose.py +++ /dev/null @@ -1,9 +0,0 @@ -import nose - -def test_compare(): - '''Test comparison of unequal strings.''' - - assert my_compare('abc', 'def') == -1 - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/construct/container.cmd b/code/construct/container.cmd deleted file mode 100755 index 0cadb46..0000000 --- a/code/construct/container.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> whole = 'selenium' ->>> for i in range(len(whole)/2): -... print whole -... whole = whole[1:-1] -selenium -eleniu -leni -ni diff --git a/code/construct/default_call.cmd b/code/construct/default_call.cmd deleted file mode 100755 index b6b382c..0000000 --- a/code/construct/default_call.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> numbers = [10, 20, 30] ->>> print "total(numbers, 0, 3):", total(numbers, 0, 3) -total(numbers, 0, 3): 60 ->>> print "total(numbers, 2):", total(numbers, 2) -total(numbers, 2): 30 ->>> print "total(numbers):", total(numbers) -total(numbers): 60 diff --git a/code/construct/default_define.py b/code/construct/default_define.py deleted file mode 100755 index a3ef7c6..0000000 --- a/code/construct/default_define.py +++ /dev/null @@ -1,16 +0,0 @@ -def total(values, start=0, end=None): - '''Add up the values in a list. If none are given, the total is zero. If - 'start' is not specified, start at the beginning. If 'end' is specified, - go up to but not including that index; otherwise, go to the end of the - list.''' - - if not values: - return 0 - - if end is None: - end = len(values) - - result = 0 - for i in range(start, end): - result += values[i] - return result diff --git a/code/construct/exceptelse.cmd b/code/construct/exceptelse.cmd deleted file mode 100755 index c436b6f..0000000 --- a/code/construct/exceptelse.cmd +++ /dev/null @@ -1,12 +0,0 @@ ->>> def invert(x): -... try: -... i = 1.0 / x -... except: -... print 'caught exception for', x -... else: -... print 'reciprocal of', x, 'is', i -... ->>> invert(1) -reciprocal of 1 is 1.0 ->>> invert(0) -caught exception for 0 diff --git a/code/construct/exceptfunc.cmd b/code/construct/exceptfunc.cmd deleted file mode 100755 index 04288b7..0000000 --- a/code/construct/exceptfunc.cmd +++ /dev/null @@ -1,14 +0,0 @@ -def average(nums): - sum = 0.0 - for n in nums: - sum += n - return sum / len(nums) -...other function definitions skipped... - -values = read_values_from_file() -try: - print 'average:', average(values) - print 'median:', median(values) - print 'standard deviation:', std_dev(values) -except ArithmeticError: - print 'Error in calculations' diff --git a/code/construct/exceptobj.cmd b/code/construct/exceptobj.cmd deleted file mode 100755 index 50f605a..0000000 --- a/code/construct/exceptobj.cmd +++ /dev/null @@ -1,13 +0,0 @@ ->>> values = [-1, 0, 1] ->>> for i in range(4): # one more than len(values) -... try: -... r = 1.0 / values[i] -... print 'reciprocal of', values[i], 'at', i, 'is', r -... except IndexError, e: -... print 'error:', e -... except ArithmeticError, e: -... print 'error:', e -reciprocal of -1 at 0 is -1.0 -error: float division -reciprocal of 1 at 2 is 1.0 -error: list index out of range diff --git a/code/construct/excepttype.cmd b/code/construct/excepttype.cmd deleted file mode 100755 index 370d89b..0000000 --- a/code/construct/excepttype.cmd +++ /dev/null @@ -1,13 +0,0 @@ ->>> values = [-1, 0, 1] ->>> for i in range(4): # one more than len(values) -... try: -... r = 1.0 / values[i] -... print 'reciprocal of', values[i], 'at', i, 'is', r -... except IndexError: -... print 'index', i, 'out of range' -... except ArithmeticError: -... print 'unable to calculate reciprocal of', values[i] -reciprocal of -1 at 0 is -1.0 -unable to calculate reciprocal of 0 -reciprocal of 1 at 2 is 1.0 -index 3 out of range diff --git a/code/construct/fixedvalue.cmd b/code/construct/fixedvalue.cmd deleted file mode 100755 index c96f554..0000000 --- a/code/construct/fixedvalue.cmd +++ /dev/null @@ -1,11 +0,0 @@ ->>> SECONDS_PER_DAY = 24 * 60 * 60 ->>> instant = 10**3 ->>> while instant <= 10**7: -... print "%10d seconds is %8.2f days" % \ -... (instant, (1.0 * instant / SECONDS_PER_DAY)) -... instant *= 10 - 1000 seconds is 0.01 days - 10000 seconds is 0.12 days - 100000 seconds is 1.16 days - 1000000 seconds is 11.57 days - 10000000 seconds is 115.74 days \ No newline at end of file diff --git a/code/construct/gatherer.py b/code/construct/gatherer.py deleted file mode 100755 index ff34173..0000000 --- a/code/construct/gatherer.py +++ /dev/null @@ -1,7 +0,0 @@ -def add_up(values): - '''Return the sum of the values in a list, or 0 if the list is empty.''' - - result = 0 - for sum in values: - result += sum - return result diff --git a/code/construct/largethresh.py b/code/construct/largethresh.py deleted file mode 100755 index 25702ae..0000000 --- a/code/construct/largethresh.py +++ /dev/null @@ -1,17 +0,0 @@ -def largest_below_threshold(values, threshold): - '''Find the largest value below a specified threshold. If no value is - found, returns None.''' - - result = None - for v in values: - if v < threshold: - result = v - break - - if result is None: - return None - - for v in values: - if result < v < threshold: - result = v - return result \ No newline at end of file diff --git a/code/construct/minmaxexercise.py b/code/construct/minmaxexercise.py deleted file mode 100755 index e7abee2..0000000 --- a/code/construct/minmaxexercise.py +++ /dev/null @@ -1,15 +0,0 @@ -def find_min_max(values): - '''Print the minimum and maximum value from the given collection of - values.''' - - min = None - max = None - - for value in values: - if value > max: - max = value - if value < min: - min = value - - print 'The minimum value is %s' % min - print 'The maximum value is %s' % max diff --git a/code/construct/mostrecent.py b/code/construct/mostrecent.py deleted file mode 100755 index 586e51e..0000000 --- a/code/construct/mostrecent.py +++ /dev/null @@ -1,12 +0,0 @@ -# A really simple number-guessing game -while True: - input = raw_input('Enter a number: ') - try: - val = int(input) - except ValueError: - print 'I said, a *number*...' - if val == 7: - print 'You guessed it!' - break - else: - print 'Try again' diff --git a/code/construct/named_params.cmd b/code/construct/named_params.cmd deleted file mode 100755 index f971822..0000000 --- a/code/construct/named_params.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> def describe_creature(name, species, age, weight): -... return '%s (%s): %d years, %d kg' % (name, species, age, weight) -... ->>> print describe_creature(name='Charles Darwin', species='Homo sapiens', - age=28, weight=70) -Charles Darwin (Homo sapiens): 28 years, 70 kg diff --git a/code/construct/named_params_2.cmd b/code/construct/named_params_2.cmd deleted file mode 100755 index 11ed882..0000000 --- a/code/construct/named_params_2.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> print describe_creature(weight=70, species='Homo sapiens', - age=28, name='Charles Darwin') -Charles Darwin (Homo sapiens): 28 years, 70 kg diff --git a/code/construct/our_max.cmd b/code/construct/our_max.cmd deleted file mode 100755 index f327af5..0000000 --- a/code/construct/our_max.cmd +++ /dev/null @@ -1,17 +0,0 @@ ->>> def our_max(*values): -... '''Find the maximum of any number of values.''' -... -... if not values: -... return None -... m = values[0] -... for v in values[1:]: -... if v > m: -... m = v -... return m -... ->>> our_max(1) -1 ->>> our_max(1, 2) -2 ->>> our_max(3, 1, 2, 5, 4, -17) -5 diff --git a/code/construct/raise.cmd b/code/construct/raise.cmd deleted file mode 100755 index 93745dd..0000000 --- a/code/construct/raise.cmd +++ /dev/null @@ -1,15 +0,0 @@ ->>> def divide(top, bottom): -... if bottom == 0: -... raise ValueError('divisor is zero') -... else: -... return top / bottom -... ->>> for i in range(-1, 2): -... try: -... print divide(1, i) -... except ValueError, e: -... print 'caught exception for', i -... --1 -caught exception for 0 -1 diff --git a/code/construct/reciprocalexercise.py b/code/construct/reciprocalexercise.py deleted file mode 100755 index 51a3bd2..0000000 --- a/code/construct/reciprocalexercise.py +++ /dev/null @@ -1,9 +0,0 @@ -def compute_reciprocals(values): - '''Return a list of the reciprocals of the given list of values. - If a value has no reciprocal, it will be assigned a value of - None in the returned list.''' - - reciprocals = [] - for value in values: - reciprocals.append(1 / value) - return reciprocals diff --git a/code/construct/remove_all.py b/code/construct/remove_all.py deleted file mode 100755 index fee2560..0000000 --- a/code/construct/remove_all.py +++ /dev/null @@ -1,19 +0,0 @@ -empty_list = [] -one_item_list = ['He'] -multi_item_list = ['Ne', 'Ar', 'He', 'He'] - -def test_remove_from_empty(): - remove_all(empty_list, 'He') - assert len(empty_list) == 0 - -def test_remove_from_one_item_list(): - remove_all(one_item_list, 'He') - assert len(one_item_list) == 0 - -def test_remove_something_else(): - remove_all(one_item_list, 'Pb') - assert len(one_item_list) == 1 - -def test_remove_multiple(): - remove_all(multi_item_list, 'He') - assert len(multi_item_list) == 2 diff --git a/code/construct/roleexercise1.py b/code/construct/roleexercise1.py deleted file mode 100755 index 2141250..0000000 --- a/code/construct/roleexercise1.py +++ /dev/null @@ -1,10 +0,0 @@ -def find_last(filename, string): - v0 = 0 - v1 = [None, None] - v2 = open(filename, "r") - for v3 in v2: - v0 += 1 - if string in v3: - v1 = [v0, v3] - return v1 - diff --git a/code/construct/roleexercise2.py b/code/construct/roleexercise2.py deleted file mode 100755 index 89314b0..0000000 --- a/code/construct/roleexercise2.py +++ /dev/null @@ -1,12 +0,0 @@ -from math import sqrt - -def standard_deviation(values): - v0 = 0.0 - for v1 in values: - v0 += v1 - v2 = v0 / len(values) - v3 = 0.0 - for v4 in values: - v3 += (v4 - v2) ** 2 - v5 = v3 / len(values) - return sqrt(v5) \ No newline at end of file diff --git a/code/construct/roleexercise3.py b/code/construct/roleexercise3.py deleted file mode 100755 index 0485d77..0000000 --- a/code/construct/roleexercise3.py +++ /dev/null @@ -1,16 +0,0 @@ -def mean(values): - '''Return the arithmetic mean of the list of values; i.e. the - sum of all the values divided by the total number of values. - If the list contains non-numeric elements, this function throws - a ValueError.''' - -def median(values): - '''Return the median of the list of values. For an odd number - of values, if the numbers are sorted, the median occurs at the - center of the list. For an even number of values, the median is - the mean of the two middle values in the sorted list of values.''' - -def mode(values): - '''Return a list containing the mode of the list of values. The - mode is the most frequently occurring values in the list. For example, - the mode of [0, 1, 0, 3, 2, 4, 1] is [0, 1].''' diff --git a/code/construct/roots.py b/code/construct/roots.py deleted file mode 100755 index bd89ab2..0000000 --- a/code/construct/roots.py +++ /dev/null @@ -1,11 +0,0 @@ -from math import sqrt - -def roots(a, b, c): - '''Return real roots of a quadratic, or None.''' - temp = b**2 - 4*a*c - if temp < 0: - return None - temp = sqrt(temp) - left = (-b + temp) / (2 * a) - right = (-b - temp) / (2 * a) - return left, right diff --git a/code/construct/roots_full.py b/code/construct/roots_full.py deleted file mode 100755 index f0a5ffa..0000000 --- a/code/construct/roots_full.py +++ /dev/null @@ -1,8 +0,0 @@ -from math import sqrt -def roots(a, b, c): - '''Return real roots of a quadratic, or None.''' - if sqrt(b**2 - 4*a*c) < 0: - return None - left = (-b + sqrt(b*2 - 4*a*c)) / (2 * a) - right = (-b - sqrt(b**2 - 4*a*c)) / (2 * a) - return left, right diff --git a/code/construct/running_sum_tdd.py b/code/construct/running_sum_tdd.py deleted file mode 100755 index ecf73d2..0000000 --- a/code/construct/running_sum_tdd.py +++ /dev/null @@ -1,38 +0,0 @@ -import nose - -def test_empty_list(): - assert running_sum([]) == [] - -def test_single_value(): - assert running_sum([1]) == [1] - - -def test_two_values(): - assert running_sum([1, 3]) == [1, 4] - -def test_three_values(): - assert running_sum([1, 3, 7]) == [1, 4, 11] - -def test_negative_values(): - assert running_run([-1, 1]) == [-1, 0] - -def test_mixed_types(): - assert running_sum([1, 3.0]) == [1, 4.0] - -def test_string(): - try: - running_sum('string') - assert False - except ValueError: - pass - except: - assert False - -def test_non_numeric(): - try: - running_sum(['string']) - assert False - except ValueError: - pass - except: - assert False diff --git a/code/construct/simpletry.cmd b/code/construct/simpletry.cmd deleted file mode 100755 index 099f01f..0000000 --- a/code/construct/simpletry.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> try: -... x = 1/0.3 -... print 'reciprocal of 0.3 is', x -... x = 1/0.0 -... print 'reciprocal of 0.0 is', x -... except: -... print 'error: no reciprocal' -reciprocal of 0.3 is 3.33333333333 -error: no reciprocal diff --git a/code/construct/summationexercise.py b/code/construct/summationexercise.py deleted file mode 100755 index f25960c..0000000 --- a/code/construct/summationexercise.py +++ /dev/null @@ -1,9 +0,0 @@ -def summation(limit): - '''Return the sum of the numbers from 0 to limit.''' - - total = 0 - current = limit - while current != 0: - total += current - current -= 1 - return total \ No newline at end of file diff --git a/code/construct/test_side_effects.py b/code/construct/test_side_effects.py deleted file mode 100755 index 44d01d7..0000000 --- a/code/construct/test_side_effects.py +++ /dev/null @@ -1,17 +0,0 @@ -import nose - -numbers = [1, 3, -1, 5] - -def test_max(): - assert max(numbers) == 5 - -def test_min(): - assert min(numbers) == -1 - -def test_append(): - old_len = len(numbers) - numbers.append(99) - assert len(numbers) == old_len + 1 - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/construct/testfloat.py b/code/construct/testfloat.py deleted file mode 100755 index fb77ec6..0000000 --- a/code/construct/testfloat.py +++ /dev/null @@ -1,21 +0,0 @@ -from math import abs -from mylibrary import average - -test_cases = [ - [0.0, [ 0.0]], - [0.0, [-1.0, 1.0]], - [1.0, [ 0.0, 2.0]], - [2.0, [ 0.0, 1.0, 2.0, 3.0, 4.0]], - .... -] - -passes = failures = 0 -for (expected, values) in test_cases: - actual = average(values) - if actual == expected: - passes += 1 - else: - failures += 1 - -print 'passes:', passes -print 'failures:', failures diff --git a/code/construct/testsalt.py b/code/construct/testsalt.py deleted file mode 100755 index 53f28cb..0000000 --- a/code/construct/testsalt.py +++ /dev/null @@ -1,23 +0,0 @@ -Bases = set(["Mg"]) # nothing but magnesium -Acids = set(["Cl"]) # nothing but chlorine - -def test_MgCl(): - '''Works if the base is a base, and the acid is an acid.''' - - assert is_salt("Mg", "Cl") - -def test_ArCl(): - '''Doesn't work because the 'base' isn't a base.''' - - assert not is_salt("Ar", "Cl") - -def test_MgO(): - '''Doesn't work because the 'acid' isn't an acid.''' - - assert not is_salt("Mg", "O") - -def test_neither(): - '''Doesn't work because neither is right.''' - - assert not is_salt("Ar", "O") - diff --git a/code/construct/uncaught.py b/code/construct/uncaught.py deleted file mode 100755 index 6485d68..0000000 --- a/code/construct/uncaught.py +++ /dev/null @@ -1,7 +0,0 @@ -values = [-1, 0, 1] -for i in range(4): # one more than len(values) - try: - r = 1.0 / values[i] - print 'reciprocal of', values[i], 'at', i, 'is', r - except IndexError, e: - print 'error:', e diff --git a/code/db/db_add_tables.cmd b/code/db/db_add_tables.cmd deleted file mode 100755 index 802e3fb..0000000 --- a/code/db/db_add_tables.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> cur.execute('CREATE TABLE PopByCountry(Region TEXT, Country TEXT, - Population INTEGER)') diff --git a/code/db/db_aggregate.cmd b/code/db/db_aggregate.cmd deleted file mode 100755 index 5fc58e9..0000000 --- a/code/db/db_aggregate.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> cur.execute('SELECT SUM (Population) FROM PopByRegion') ->>> cur.fetchone() -(8965762,) diff --git a/code/db/db_commit.cmd b/code/db/db_commit.cmd deleted file mode 100755 index 21e0d8b..0000000 --- a/code/db/db_commit.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> con.commit() diff --git a/code/db/db_connect.cmd b/code/db/db_connect.cmd deleted file mode 100755 index 7103f69..0000000 --- a/code/db/db_connect.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> con = dbapi.connect('population.db') \ No newline at end of file diff --git a/code/db/db_constraint.cmd b/code/db/db_constraint.cmd deleted file mode 100755 index 25bf8aa..0000000 --- a/code/db/db_constraint.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> cur.execute(''' -CREATE TABLE PopByCountry( - Region TEXT NOT NULL, - Country TEXT NOT NULL, - Population INTEGER NOT NULL, - CONSTRAINT Country_Key PRIMARY KEY (Region, Country)) -''') - diff --git a/code/db/db_create.cmd b/code/db/db_create.cmd deleted file mode 100755 index b0b18f5..0000000 --- a/code/db/db_create.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> cur.execute('CREATE TABLE PopByRegion(Region TEXT, Population INTEGER)') - diff --git a/code/db/db_cursor.cmd b/code/db/db_cursor.cmd deleted file mode 100755 index 2433956..0000000 --- a/code/db/db_cursor.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> cur = con.cursor() \ No newline at end of file diff --git a/code/db/db_delete.cmd b/code/db/db_delete.cmd deleted file mode 100755 index 894ed11..0000000 --- a/code/db/db_delete.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> cur.execute('DELETE FROM PopByRegion WHERE Region < "L"') ->>> cur.execute('SELECT * FROM PopByRegion'); ->>> cur.fetchall() -[('Southeastern Africa', 743112), ('Northern Africa', 1037463), -('Southern Asia', 2051941), ('Middle East', 687630), ('South America', -593121), ('North America', 661157), ('Western Europe', 387933)] diff --git a/code/db/db_delete_2.cmd b/code/db/db_delete_2.cmd deleted file mode 100755 index 8de9778..0000000 --- a/code/db/db_delete_2.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> cur.execute('INSERT INTO PopByRegion VALUES ("Japan", 100562)') diff --git a/code/db/db_distinct.cmd b/code/db/db_distinct.cmd deleted file mode 100755 index 7430ff8..0000000 --- a/code/db/db_distinct.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> cur.execute(''' -SELECT DISTINCT PopByRegion.Region -FROM PopByRegion INNER JOIN PopByCountry -WHERE (PopByRegion.Region = PopByCountry.Region) -AND ((PopByCountry.Population * 1.0) / PopByRegion.Population > 0.10)''') ->>> print cur.fetchall() -[('Eastern Asia',), ('North America',)] diff --git a/code/db/db_drop.cmd b/code/db/db_drop.cmd deleted file mode 100755 index 1f0f1a5..0000000 --- a/code/db/db_drop.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> cur.execute('DROP TABLE PopByRegion'); diff --git a/code/db/db_duplicates.cmd b/code/db/db_duplicates.cmd deleted file mode 100755 index 4bad6a2..0000000 --- a/code/db/db_duplicates.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> cur.execute(''' -SELECT PopByRegion.Region -FROM PopByRegion INNER JOIN PopByCountry -WHERE (PopByRegion.Region = PopByCountry.Region) -AND ((PopByCountry.Population * 1.0) / PopByRegion.Population > 0.10)''') ->>> print cur.fetchall() -[('Eastern Asia',), ('North America',), ('North America',)] \ No newline at end of file diff --git a/code/db/db_fetchone.cmd b/code/db/db_fetchone.cmd deleted file mode 100755 index 7d094df..0000000 --- a/code/db/db_fetchone.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> print cur.fetchone() -(u'Central Africa', 330993) \ No newline at end of file diff --git a/code/db/db_fetchone_2.cmd b/code/db/db_fetchone_2.cmd deleted file mode 100755 index b4ccbff..0000000 --- a/code/db/db_fetchone_2.cmd +++ /dev/null @@ -1,3 +0,0 @@ -con.text_factory = str ->>> print cur.fetchone() -('Northern Africa', 1037163) \ No newline at end of file diff --git a/code/db/db_group.cmd b/code/db/db_group.cmd deleted file mode 100755 index e73eb2d..0000000 --- a/code/db/db_group.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> cur.execute('SELECT SUM (Population) FROM PopByCountry GROUP BY Region') ->>> cur.fetchall() -[(1364389,), (661200,)] diff --git a/code/db/db_import.cmd b/code/db/db_import.cmd deleted file mode 100755 index f96a002..0000000 --- a/code/db/db_import.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> import sqlite3 as dbapi diff --git a/code/db/db_inner_join.cmd b/code/db/db_inner_join.cmd deleted file mode 100755 index 5d54093..0000000 --- a/code/db/db_inner_join.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> cur.execute(''' -SELECT PopByRegion.Region, PopByCountry.Country -FROM PopByRegion INNER JOIN PopByCountry -WHERE (PopByRegion.Region = PopByCountry.Region) -AND (PopByRegion.Population > 1000000) -''') ->>> print cur.fetchall() -[('Eastern Asia', 'China'), ('Eastern Asia', 'DPR Korea'), -('Eastern Asia', 'Hong Kong (China)'), ('Eastern Asia', 'Mongolia'), -('Eastern Asia', 'Republic of Korea'), ('Eastern Asia', 'Taiwan')] diff --git a/code/db/db_insert.cmd b/code/db/db_insert.cmd deleted file mode 100755 index 6528777..0000000 --- a/code/db/db_insert.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> cur.execute('INSERT INTO PopByRegion VALUES("Central Africa", 330993)') ->>> cur.execute('INSERT INTO PopByRegion VALUES("Southeastern Africa", 743112)') -... ->>> cur.execute('INSERT INTO PopByRegion VALUES("Japan", 100562)') diff --git a/code/db/db_insert_2.cmd b/code/db/db_insert_2.cmd deleted file mode 100755 index 9b9dba1..0000000 --- a/code/db/db_insert_2.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> cur.execute('INSERT INTO PopByCountry VALUES("Eastern Asia", "China", - 1285238)') diff --git a/code/db/db_insert_3.cmd b/code/db/db_insert_3.cmd deleted file mode 100755 index a0ade15..0000000 --- a/code/db/db_insert_3.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> countries = [("Eastern Asia", "DPR Korea", 24056), ("Eastern Asia", -"Hong Kong (China)", 8764), ("Eastern Asia", "Mongolia", 3407), ("Eastern -Asia", "Republic of Korea", 41491), ("Eastern Asia", "Taiwan", 1433), -("North America", "Bahamas", 368), ("North America", "Canada", 40876), -("North America", "Greenland", 43), ("North America", "Mexico", 126875), -("North America", "United States", 493038)] ->>> for c in countries: -... cur.execute('INSERT INTO PopByCountry VALUES (?, ?, ?)', (c[0], c[1], c[2])) -... ->>> con.commit() diff --git a/code/db/db_more_queries.cmd b/code/db/db_more_queries.cmd deleted file mode 100755 index 2d88e86..0000000 --- a/code/db/db_more_queries.cmd +++ /dev/null @@ -1,11 +0,0 @@ ->>> cur.execute('SELECT Region FROM PopByRegion') -[('Central Africa',), ('Southeastern Africa',), ('Northern Africa',), -('Southern Asia',), ('Asia Pacific',), ('Middle East',), ('Eastern -Asia',), ('South America',), ('Eastern Europe',), ('North America',), -('Western Europe',), ('Japan',)] ->>> cur.execute('SELECT * FROM PopByRegion') -[('Central Africa', 330993), ('Southeastern Africa', 743112), -('Northern Africa', 1037463), ('Southern Asia', 2051941), ('Asia -Pacific', 785468), ('Middle East', 687630), ('Eastern Asia', 1362955), -('South America', 593121), ('Eastern Europe', 223427), ('North -America', 661157), ('Western Europe', 387933), ('Japan', 100562)] diff --git a/code/db/db_mysql.cmd b/code/db/db_mysql.cmd deleted file mode 100755 index 1a81608..0000000 --- a/code/db/db_mysql.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> import MySQLdb as dbapi diff --git a/code/db/db_nested_1.cmd b/code/db/db_nested_1.cmd deleted file mode 100755 index b00928d..0000000 --- a/code/db/db_nested_1.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> cur.execute(''' -SELECT DISTINCT Region -FROM PopByCountry -WHERE (PopByCountry.Population != 8764) -''') ->>> cur.fetchall() -[('Eastern Asia',), ('North America',)] diff --git a/code/db/db_nested_2.cmd b/code/db/db_nested_2.cmd deleted file mode 100755 index e09c8fc..0000000 --- a/code/db/db_nested_2.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> cur.execute(''' -SELECT DISTINCT Region -FROM PopByCountry -WHERE (PopByCountry.Population = 8764) -''') ->>> cur.fetchall() -[('Eastern Asia',) diff --git a/code/db/db_nested_3.cmd b/code/db/db_nested_3.cmd deleted file mode 100755 index d2e25fd..0000000 --- a/code/db/db_nested_3.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> cur.execute(''' -SELECT DISTINCT Region -FROM PopByCountry -WHERE Region NOT IN - (SELECT DISTINCT Region - FROM PopByCountry - WHERE (PopByCountry.Population = 8764)) -''') ->>> cur.fetchall() -[('North America',)] diff --git a/code/db/db_null.cmd b/code/db/db_null.cmd deleted file mode 100755 index b7239a5..0000000 --- a/code/db/db_null.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> cur.execute('INSERT INTO PopByRegion VALUES ("Mars", NULL)') diff --git a/code/db/db_null_2.cmd b/code/db/db_null_2.cmd deleted file mode 100755 index 409ca35..0000000 --- a/code/db/db_null_2.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> cur.execute('CREATE TABLE Test (Region TEXT NOT NULL, Population INTEGER)') diff --git a/code/db/db_null_3.cmd b/code/db/db_null_3.cmd deleted file mode 100755 index 2b8a39d..0000000 --- a/code/db/db_null_3.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> cur.execute('INSERT INTO Test VALUES (NULL, 456789)') -Traceback (most recent call last): - File "", line 1, in -sqlite3.dbapi2.IntegrityError: Test.Region may not be NULL - diff --git a/code/db/db_primary_key.cmd b/code/db/db_primary_key.cmd deleted file mode 100755 index e80f7f7..0000000 --- a/code/db/db_primary_key.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> cur.execute('CREATE TABLE PopByRegion (Region TEXT NOT NULL, - Population INTEGER NOT NULL, PRIMARY KEY (Region))'); - diff --git a/code/db/db_query_allYear2300.cmd b/code/db/db_query_allYear2300.cmd deleted file mode 100755 index 9eaa907..0000000 --- a/code/db/db_query_allYear2300.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> cur.execute('SELECT Region, Population FROM PopByRegion') diff --git a/code/db/db_query_allYear2300_2.cmd b/code/db/db_query_allYear2300_2.cmd deleted file mode 100755 index de06ccd..0000000 --- a/code/db/db_query_allYear2300_2.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> print cur.fetchall() -[('Souteastern Africa', 743112), ('Asia Pacific', 785468), ('Middle East', -687630), ('Eastern Asia', 1362955), ('South America', 593121), ('Eastern - Europe', 223427), ('North America', 661157), ('Western Europe', 387933), - ('Japan', 100562)] \ No newline at end of file diff --git a/code/db/db_query_sort.cmd b/code/db/db_query_sort.cmd deleted file mode 100755 index 817a7bd..0000000 --- a/code/db/db_query_sort.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> cur.execute('SELECT Region, Population FROM PopByRegion ORDER BY Region') ->>> cur.fetchall() -[('Asia Pacific', 785468), ('Central Africa', 330993), ('Eastern -Asia', 1362955), ('Eastern Europe', 223427), ('Japan', 100562), -('Middle East', 687630), ('North America', 661157), ('Northern -Africa', 1037463), ('South America', 593121), ('Southeastern Africa', -743112), ('Southern Asia', 2051941), ('Western Europe', 387933)] diff --git a/code/db/db_query_sort_2.cmd b/code/db/db_query_sort_2.cmd deleted file mode 100755 index dc68378..0000000 --- a/code/db/db_query_sort_2.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> cur.execute('SELECT Region, Population FROM PopByRegion - ORDER BY Population DESC') ->>> cur.fetchall() -[('Southern Asia', 2051941), ('Eastern Asia', 1362955), ('Northern -Africa', 1037463), ('Asia Pacific', 785468), ('Southeastern Africa', -743112), ('Middle East', 687630), ('North America', 661157), ('South -America', 593121), ('Western Europe', 387933), ('Central Africa', -330993), ('Eastern Europe', 223427), ('Japan', 100562)] diff --git a/code/db/db_self1.cmd b/code/db/db_self1.cmd deleted file mode 100755 index 6b0ff61..0000000 --- a/code/db/db_self1.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> cur.execute('SELECT Country FROM PopByCountry - WHERE (ABS(Population - Population) < 1000)') ->>> cur.fetchall() -[('China',), ('DPR Korea',), ('Hong Kong (China)',), ('Mongolia',), -('Republic of Korea',), ('Taiwan',), ('Bahamas',), ('Canada',), -('Greenland',), ('Mexico',), ('United States',)] - diff --git a/code/db/db_self_join.cmd b/code/db/db_self_join.cmd deleted file mode 100755 index 3569e08..0000000 --- a/code/db/db_self_join.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> cur.execute(''' -SELECT A.Country, B.Country -FROM PopByCountry A INNER JOIN PopByCountry B -WHERE (ABS(A.Population - B.Population) <= 1000) -AND (A.Country != B.Country)''') ->>> cur.fetchall() -[('Republic of Korea', 'Canada'), ('Bahamas', 'Greenland'), ('Canada', -'Republic of Korea'), ('Greenland', 'Bahamas')] diff --git a/code/db/db_setup.py b/code/db/db_setup.py deleted file mode 100755 index e14cf55..0000000 --- a/code/db/db_setup.py +++ /dev/null @@ -1,30 +0,0 @@ -import sqlite3 as dbapi - -con = dbapi.connect('pop.db') -cur = con.cursor() - -cur.execute('CREATE TABLE PopByRegion(Region TEXT, Population INEGER)') - -cur.execute('INSERT INTO PopByRegion VALUES("Central Africa", 330993)') -cur.execute('INSERT INTO PopByRegion VALUES("Southeastern Africa", 743112)') -cur.execute('INSERT INTO PopByRegion VALUES("Northern Africa", 1037463)') -cur.execute('INSERT INTO PopByRegion VALUES("Southern Asia", 2051941)') -cur.execute('INSERT INTO PopByRegion VALUES("Asia Pacific", 785468)') -cur.execute('INSERT INTO PopByRegion VALUES("Middle East", 687630)') -cur.execute('INSERT INTO PopByRegion VALUES("Eastern Asia", 1362955)') -cur.execute('INSERT INTO PopByRegion VALUES("South America", 593121)') -cur.execute('INSERT INTO PopByRegion VALUES("Eastern Europe", 223427)') -cur.execute('INSERT INTO PopByRegion VALUES("North America", 661157)') -cur.execute('INSERT INTO PopByRegion VALUES("Western Europe", 387933)') -cur.execute('INSERT INTO PopByRegion VALUES("Japan", 100562)') - -con.commit() - -cur.execute('CREATE TABLE PopByCountry(Region TEXT, Country TEXT, Population INEGER)') - -countries = [("Eastern Asia", "China", 1285238), ("Eastern Asia", "DPR Korea", 24056), ("Eastern Asia", "Hong Kong (China)", 8764), ("Eastern Asia", "Mongolia", 3407), ("Eastern Asia", "Republic of Korea", 41491), ("Eastern Asia", "Taiwan", 1433), ("North America", "Bahamas", 368), ("North America", "Canada", 40876), ("North America", "Greenland", 43), ("North America", "Mexico", 126875), ("North America", "United States", 493038)] - -for c in countries: - cur.execute('INSERT INTO PopByCountry VALUES (?, ?, ?)', (c[0], c[1], c[2])) - -con.commit() \ No newline at end of file diff --git a/code/db/db_transaction_1.cmd b/code/db/db_transaction_1.cmd deleted file mode 100755 index d21e7c5..0000000 --- a/code/db/db_transaction_1.cmd +++ /dev/null @@ -1,5 +0,0 @@ -cur.execute('SELECT SignedOut FROM Books WHERE ISBN = "%s"' % isbn) -signedOut = cur.fetchone()[0] -cur.execute('UPDATE Books SET SignedOut = %d - WHERE ISBN = "%s"' % (signedOut + 1, isbn)) -cur.commit() diff --git a/code/db/db_transaction_2.cmd b/code/db/db_transaction_2.cmd deleted file mode 100755 index 2225a53..0000000 --- a/code/db/db_transaction_2.cmd +++ /dev/null @@ -1,5 +0,0 @@ -cur.execute('SELECT SignedOut FROM Books WHERE ISBN = "%s"' % isbn) -signedOut = cur.fetchone()[0] -cur.execute('UPDATE Books SET SignedOut = %d - WHERE ISBN = "%s"' % (signedOut - 1, isbn)) -cur.commit() diff --git a/code/db/db_transaction_3.cmd b/code/db/db_transaction_3.cmd deleted file mode 100755 index 7f92958..0000000 --- a/code/db/db_transaction_3.cmd +++ /dev/null @@ -1,10 +0,0 @@ -Computer A: cur.execute('SELECT SignedOut FROM Books WHERE ISBN = "%s"' % isbn) -Computer A: signedOut = cur.fetchone()[0] -Computer B: cur.execute('SELECT SignedOut FROM Books WHERE ISBN = "%s"' % isbn) -Computer B: signedOut = cur.fetchone()[0] -Computer A: cur.execute('UPDATE Books SET SignedOut = %d - WHERE ISBN = "%s"' % (signedOut + 1, isbn)) -Computer A: cur.commit() -Computer B: cur.execute('UPDATE Books SET SignedOut = %d - WHERE ISBN = "%s"' % (signedOut - 1, isbn)) -Computer B: cur.commit() diff --git a/code/db/db_update.cmd b/code/db/db_update.cmd deleted file mode 100755 index 495a62f..0000000 --- a/code/db/db_update.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> cur.execute('SELECT * FROM PopByRegion WHERE Region = "Japan"') ->>> cur.fetchone() -('Japan', 100562) ->>> cur.execute('UPDATE PopByRegion SET Population = 100600 - WHERE Region = "Japan"') ->>> cur.execute('SELECT * FROM PopByRegion WHERE Region = "Japan"') ->>> cur.fetchone() -('Japan', 100600) diff --git a/code/db/db_where.cmd b/code/db/db_where.cmd deleted file mode 100755 index f0b616a..0000000 --- a/code/db/db_where.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> cur.execute('SELECT Region FROM PopByRegion WHERE Population > 1000000') ->>> print cur.fetchall() -[('Northern Africa',), ('Southern Asia',), ('Eastern Asia',))] diff --git a/code/db/db_where_2.cmd b/code/db/db_where_2.cmd deleted file mode 100755 index b830ab9..0000000 --- a/code/db/db_where_2.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> cur.execute('SELECT Region FROM PopByRegion - WHERE Population > 1000000 AND Region < "L"') ->>> print cur.fetchall() -[('Eastern Asia',))] diff --git a/code/fileproc/ammonia.pdb b/code/fileproc/ammonia.pdb deleted file mode 100755 index da1db05..0000000 --- a/code/fileproc/ammonia.pdb +++ /dev/null @@ -1,6 +0,0 @@ -COMPND AMMONIA -ATOM 1 N 0.257 -0.363 0.000 -ATOM 2 H 0.257 0.727 0.000 -ATOM 3 H 0.771 -0.727 0.890 -ATOM 4 H 0.771 -0.727 -0.890 -END diff --git a/code/fileproc/append.py b/code/fileproc/append.py deleted file mode 100755 index 57f62da..0000000 --- a/code/fileproc/append.py +++ /dev/null @@ -1,3 +0,0 @@ -output_file = open("test.txt", "a") -ouput_file.write("Software Engineering") -output_file.close() \ No newline at end of file diff --git a/code/fileproc/fixed_width_1.py b/code/fileproc/fixed_width_1.py deleted file mode 100755 index 6e1ae59..0000000 --- a/code/fileproc/fixed_width_1.py +++ /dev/null @@ -1,32 +0,0 @@ -def read_weather_data(r): - '''Read weather data from reader r in fixed-width format. - The fields are: - 1 8 YYYYMMDD (date) - 9 14 DDMMSS (latitude) - 15 20 DDMMSS (longitude) - 21 26 FF.FFF (temp, deg. C) - 27 32 FF.FFF (humidity, %) - 33 38 FF.FFF (pressure, kPa) - The result is a list of tuples of tuples, - where each tuple of tuples is of the form: - ((Yr, Mo, Day), (Deg, Min, Sec), (Deg, Min, Sec), (Temp, Hum, Press)) - ''' - result = [] - for line in r: - year = int(line[0:4]) - month = int(line[4:6]) - day = int(line[6:8]) - lat_deg = int(line[8:10]) - lat_min = int(line[10:12]) - lat_sec = int(line[12:14]) - long_deg = int(line[14:16]) - long_min = int(line[16:18]) - long_sec = int(line[18:20]) - temp = float(line[20:26]) - hum = float(line[26:32]) - press = float(line[32:38]) - result.append(((year, month, day), - (lat_deg, lat_min, lat_sec), - (long_deg, long_min, long_sec), - (temp, hum, press))) - return result diff --git a/code/fileproc/fixed_width_2.py b/code/fileproc/fixed_width_2.py deleted file mode 100755 index 04c1e45..0000000 --- a/code/fileproc/fixed_width_2.py +++ /dev/null @@ -1,31 +0,0 @@ -def read_weather_data(r): - '''Read weather data from reader r in fixed-width format. - The field widths are: - 4,2,2 YYYYMMDD (date) - 2,2,2 DDMMSS (latitude) - 2,2,2 DDMMSS (longitude) - 6,6,6 FF.FFF (temp, deg. C; humidity, %; pressure, kPa) - The result is a list of tuples (not tuples of tuples), - where each tuple is of the form: - (YY, MM, DD, DD, MM, SS, DD, MM, SS, Temp, Hum, Press)''' - fields = ((4, int), (2, int), (2, int), # date - (2, int), (2, int), (2, int), # latitude - (2, int), (2, int), (2, int), # longitude - (6, float), (6, float), (6, float)) # data - result = [] - # For each record - for line in r: - start = 0 - record = [] - # for each field in the record - for (width, target_type) in fields: - # convert the text - text = line[start:start+width] - field = target_type(text) - # add it to the record - record.append(field) - # move on - start += width - # add the completed record to the result - result.append(record) - return result diff --git a/code/fileproc/hebron.txt b/code/fileproc/hebron.txt deleted file mode 100755 index 7f8647e..0000000 --- a/code/fileproc/hebron.txt +++ /dev/null @@ -1,10 +0,0 @@ -Coloured fox fur production, Hebron, Labrador, 1834-1839 -#Source: C. Elton (1942) "Voles, Mice and Lemmings", Oxford Univ. Press -#Table 17, p.265--266 -#remark: missing value for 1836 - 55 - 262 - - - 102 - 178 - 227 diff --git a/code/fileproc/hopedale.txt b/code/fileproc/hopedale.txt deleted file mode 100755 index df555bb..0000000 --- a/code/fileproc/hopedale.txt +++ /dev/null @@ -1,12 +0,0 @@ -Coloured fox fur production, HOPEDALE, Labrador, 1834-1842 -#Source: C. Elton (1942) "Voles, Mice and Lemmings", Oxford Univ. Press -#Table 17, p.265--266 - 22 - 29 - 2 - 16 - 12 - 35 - 8 - 83 - 166 diff --git a/code/fileproc/housing.dat b/code/fileproc/housing.dat deleted file mode 100755 index cf11846..0000000 --- a/code/fileproc/housing.dat +++ /dev/null @@ -1,24 +0,0 @@ - 91.3 11.358 13 - 96.3 11.355 12.62 - 134.6 16.100 12.97 - 135.8 16.315 12.02 - 174.9 19.205 12.21 - 173.2 20.263 11.9 - 161.6 16.885 12.02 - 176.8 19.441 12.01 - 154.9 17.379 12.08 - 159.3 16.028 11.8 - 136 15.401 11.82 - 108.3 13.518 11.94 - 109.1 14.023 11.8 - 130 14.442 11.78 - 137.5 17.916 11.56 - 172.7 17.655 11.55 - 180.7 21.990 11.68 - 184 20.036 11.61 - 162.1 19.224 11.91 - 147.4 19.367 11.89 - 148.5 16.923 12.03 - 152.3 18.413 12.27 - 126.2 16.616 12.27 - 98.9 14.220 12.05 diff --git a/code/fileproc/housing.py b/code/fileproc/housing.py deleted file mode 100755 index f01f0a1..0000000 --- a/code/fileproc/housing.py +++ /dev/null @@ -1,25 +0,0 @@ -import sys - -def housing(r): - '''Return the difference between the housing starts and - construction contracts in 1983 and in 1984 from reader r.''' - - # The monthly housing starts, in thousands of units. - starts = [] - - # The construction contracts, in millions of dollars. - contracts = [] - - # Read the file, populating the lists. - for line in r: - start, contract, rate = line.split() - starts.append(float(start)) - contracts.append(float(contract)) - - return (sum(starts[12:24]) - sum(starts[0:12]), - sum(contracts[12:24]) - sum(contracts[0:12])) - -if __name__ == "__main__": - input_file = open(sys.argv[1], "r") - print housing(input_file) - input_file.close() diff --git a/code/fileproc/housing_2.py b/code/fileproc/housing_2.py deleted file mode 100755 index 89a97fa..0000000 --- a/code/fileproc/housing_2.py +++ /dev/null @@ -1,30 +0,0 @@ -import sys - -def read_housing_data(r): - '''Read housing data from reader r, returning lists of starts, - contracts, and rates.''' - - starts = [] - contracts = [] - rates = [] - - for line in r: - start, contract, rate = line.split() - starts.append(float(start)) - contracts.append(float(contract)) - rates.append(rate) - - return (starts, contracts, rates) - -def process_housing_data(starts, contracts): - '''Return the difference between the housing starts and - construction contracts in 1983 and in 1984.''' - - return (sum(starts[12:24]) - sum(starts[0:12]), - sum(contracts[12:24]) - sum(contracts[0:12])) - -if __name__ == "__main__": - input_file = open(sys.argv[1], "r") - starts, contracts, rates = read_housing_data(input_file) - print process_housing_data(starts, contracts) - input_file.close() diff --git a/code/fileproc/lookahead.py b/code/fileproc/lookahead.py deleted file mode 100755 index 5fc0c8b..0000000 --- a/code/fileproc/lookahead.py +++ /dev/null @@ -1,10 +0,0 @@ -def read_all_molecules(r): - '''Read zero or more molecules from reader r, - returning a list of the molecules read.''' - - result = [] - line = r.readline() - while line: - molecule, line = read_molecule(r, line) - result.append(molecule) - return result diff --git a/code/fileproc/lookahead_2.py b/code/fileproc/lookahead_2.py deleted file mode 100755 index 75e5a6d..0000000 --- a/code/fileproc/lookahead_2.py +++ /dev/null @@ -1,17 +0,0 @@ -def read_molecule(r, line): - '''Read a molecule from reader r. The variable 'line' - is the first line of the molecule to be read; the result is - the molecule, and the first line after it (or the empty string - if the end of file has been reached).''' - - fields = line.split() - molecule = [fields[1]] - - line = r.readline() - while line and not line.startswith('COMPND'): - fields = line.split() - key, num, type, x, y, z = fields - molecule.append((type, x, y, z)) - line = r.readline() - - return molecule, line diff --git a/code/fileproc/lynx.txt b/code/fileproc/lynx.txt deleted file mode 100755 index df3e115..0000000 --- a/code/fileproc/lynx.txt +++ /dev/null @@ -1,19 +0,0 @@ -Annual Number of Lynx Trapped, MacKenzie River, 1821-1934 -#Original Source: Elton, C. and Nicholson, M. (1942) -#"The ten year cycle in numbers of Canadian lynx", -#J. Animal Ecology, Vol. 11, 215--244. -#This is the famous data set which has been listed before in -#various publications: -#Cambell, M.J. and Walker, A.M. (1977) "A survey of statistical work on -#the MacKenzie River series of annual Canadian lynx trappings for the years -#1821-1934 with a new analysis", J.Roy.Statistical Soc. A 140, 432--436. - 269. 321. 585. 871. 1475. 2821. 3928. 5943. 4950. 2577. 523. 98. - 184. 279. 409. 2285. 2685. 3409. 1824. 409. 151. 45. 68. 213. - 546. 1033. 2129. 2536. 957. 361. 377. 225. 360. 731. 1638. 2725. - 2871. 2119. 684. 299. 236. 245. 552. 1623. 3311. 6721. 4245. 687. - 255. 473. 358. 784. 1594. 1676. 2251. 1426. 756. 299. 201. 229. - 469. 736. 2042. 2811. 4431. 2511. 389. 73. 39. 49. 59. 188. - 377. 1292. 4031. 3495. 587. 105. 153. 387. 758. 1307. 3465. 6991. - 6313. 3794. 1836. 345. 382. 808. 1388. 2713. 3800. 3091. 2985. 3790. - 674. 81. 80. 108. 229. 399. 1132. 2432. 3574. 2935. 1537. 529. - 485. 662. 1000. 1590. 2657. 3396. diff --git a/code/fileproc/multimol.pdb b/code/fileproc/multimol.pdb deleted file mode 100755 index 2521006..0000000 --- a/code/fileproc/multimol.pdb +++ /dev/null @@ -1,14 +0,0 @@ -COMPND AMMONIA -ATOM 1 N 0.257 -0.363 0.000 -ATOM 2 H 0.257 0.727 0.000 -ATOM 3 H 0.771 -0.727 0.890 -ATOM 4 H 0.771 -0.727 -0.890 -END -COMPND METHANOL -ATOM 1 C -0.748 -0.015 0.024 -ATOM 2 O 0.558 0.420 -0.278 -ATOM 3 H -1.293 -0.202 -0.901 -ATOM 4 H -1.263 0.754 0.600 -ATOM 5 H -0.699 -0.934 0.609 -ATOM 6 H 0.716 1.404 0.137 -END diff --git a/code/fileproc/multimol.py b/code/fileproc/multimol.py deleted file mode 100755 index 0fc2dc5..0000000 --- a/code/fileproc/multimol.py +++ /dev/null @@ -1,13 +0,0 @@ -def read_all_molecules(r): - '''Read zero or more molecules from reader r, - returning a list of the molecules read.''' - - result = [] - reading = True - while reading: - molecule = read_molecule(r) - if molecule: - result.append(molecule) - else: - reading = False - return result diff --git a/code/fileproc/multimol_2.py b/code/fileproc/multimol_2.py deleted file mode 100755 index cb5f54f..0000000 --- a/code/fileproc/multimol_2.py +++ /dev/null @@ -1,25 +0,0 @@ -def read_molecule(r): - '''Read a single molecule from reader r and return it, - or return None to signal end of file.''' - - # If there isn't another line, we're at the end of the file. - line = r.readline() - if not line: - return None - - # Name of the molecule: "COMPND name" - key, name = line.split() - - # Other lines are either "END" or "ATOM num type x y z" - molecule = [name] - reading = True - - while reading: - line = r.readline() - if line.startswith('END'): - reading = False - else: - key, num, type, x, y, z = line.split() - molecule.append((type, x, y, z)) - - return molecule diff --git a/code/fileproc/read_file_1.py b/code/fileproc/read_file_1.py deleted file mode 100755 index 1f1efae..0000000 --- a/code/fileproc/read_file_1.py +++ /dev/null @@ -1,5 +0,0 @@ -input_file = open("hopedale.txt", "r") -for line in input_file: - line = line.strip() - print line -input_file.close() diff --git a/code/fileproc/read_file_2.py b/code/fileproc/read_file_2.py deleted file mode 100755 index f79690c..0000000 --- a/code/fileproc/read_file_2.py +++ /dev/null @@ -1,12 +0,0 @@ -import sys - -def process_file(filename): - '''Open, read, and print a file.''' - - input_file = open(filename, "r") - for line in input_file: - line = line.strip() - print line - input_file.close() -if __name__ == "__main__": - process_file(sys.argv[1]) diff --git a/code/fileproc/read_file_3.py b/code/fileproc/read_file_3.py deleted file mode 100755 index 8e530d4..0000000 --- a/code/fileproc/read_file_3.py +++ /dev/null @@ -1,13 +0,0 @@ -import sys - -def process_file(reader): - '''Read and print the contents of reader.''' - - for line in reader: - line = line.strip() - print line - -if __name__ == "__main__": - input_file = open(sys.argv[1], "r") - process_file(input_file) - input_file.close() diff --git a/code/fileproc/read_file_4.py b/code/fileproc/read_file_4.py deleted file mode 100755 index 21d6261..0000000 --- a/code/fileproc/read_file_4.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys -import urllib - -def process_file(reader): - '''Read and print the contents of reader.''' - - for line in reader: - line = line.strip() - print line - -if __name__ == "__main__": - webpage = urllib.urlopen(sys.argv[1]) - process_file(webpage) - webpage.close() diff --git a/code/fileproc/read_lynx.py b/code/fileproc/read_lynx.py deleted file mode 100755 index 4f5cc2d..0000000 --- a/code/fileproc/read_lynx.py +++ /dev/null @@ -1,38 +0,0 @@ -import sys -from tsdl import skip_header - -def find_largest(line): - '''Return the largest value in line, which is a - whitespace-delimited string of integers.''' - # The largest value seen so far. - largest = -1 - - for value in line.split(): - - # Remove the trailing period. - v = int(value[:-1]) - - # If we find a larger value, remember it. - if v > largest: - largest = v - - return largest - -def process_file(r): - '''Read and process reader r.''' - line = skip_header(r).strip() - - # The largest value so far. - largest = find_largest(line) - - # Check the rest of the lines for larger values. - for line in r: - large = find_largest(line) - if large > largest: - largest = large - - return largest -if __name__ == "__main__": - input_file = open(sys.argv[1], "r") - print process_file(input_file) - input_file.close() diff --git a/code/fileproc/read_lynx_1.py b/code/fileproc/read_lynx_1.py deleted file mode 100755 index 21694b4..0000000 --- a/code/fileproc/read_lynx_1.py +++ /dev/null @@ -1,19 +0,0 @@ -import sys - -def find_largest(line): - '''Return the largest value in line, which is a - whitespace-delimited string of integers.''' - - # The largest value seen so far. - largest = -1 - - for value in line.split(): - - # Remove the trailing period. - v = int(value[:-1]) - - # If we find a larger value, remember it. - if v > largest: - largest = v - - return largest diff --git a/code/fileproc/read_lynx_expanded.py b/code/fileproc/read_lynx_expanded.py deleted file mode 100755 index 31b94a5..0000000 --- a/code/fileproc/read_lynx_expanded.py +++ /dev/null @@ -1,40 +0,0 @@ -import sys -from tsdl import skip_header - -def process_file(r): - '''Read and process reader r.''' - - line = skip_header(r).strip() - - # The largest value seen so far. - largest = -1 - - for value in line.split(): - - # Remove the trailing period. - v = int(value[:-1]) - # If we find a larger value, remember it. - if v > largest: - largest = v - - # Check the rest of the lines for larger values. - for line in r: - # The largest value seen so far. - large = -1 - - for value in line.split(): - - # Remove the trailing period. - v = int(value[:-1]) - # If we find a larger value, remember it. - if v > large: - large = v - - if large > largest: - largest = large - - return largest -if __name__ == "__main__": - input_file = open(sys.argv[1], "r") - print process_file(input_file) - input_file.close() diff --git a/code/fileproc/read_smallest.py b/code/fileproc/read_smallest.py deleted file mode 100755 index 77c2f65..0000000 --- a/code/fileproc/read_smallest.py +++ /dev/null @@ -1,24 +0,0 @@ -import sys -import tsdl - -def smallest_value(r): - '''Read and process reader r to find the smallest - value after the TSDL header.''' - line = tsdl.skip_header(r).strip() - - # Now line contains the first data value; this is also the - # smallest value found so far, because it is the only one we have seen. - smallest = int(line) - for line in r: - line = line.strip() - value = int(line) - - # If we find a smaller value, remember it. - if value < smallest: - smallest = value - return smallest - -if __name__ == "__main__": - input_file = open(sys.argv[1], "r") - print smallest_value(input_file) - input_file.close() \ No newline at end of file diff --git a/code/fileproc/read_smallest_hebron.cmd b/code/fileproc/read_smallest_hebron.cmd deleted file mode 100755 index 6c48d01..0000000 --- a/code/fileproc/read_smallest_hebron.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> import read_smallest ->>> read_smallest.smallest_value(open('hebron.txt', - 'r'))Traceback (most recent call last): - File "", line 1, in - File "read_smallest.py", line 16, in smallest_value - value = int(line) -ValueError: invalid literal for int() with base 10: '-' \ No newline at end of file diff --git a/code/fileproc/read_smallest_skip.py b/code/fileproc/read_smallest_skip.py deleted file mode 100755 index d8d8618..0000000 --- a/code/fileproc/read_smallest_skip.py +++ /dev/null @@ -1,27 +0,0 @@ -import sys -from tsdl import skip_header -def smallest_value_skip(r): - '''Read and process reader r to find the smallest value after - the TSDL header. Skip missing values, which are indicated - with a hyphen.''' - line = skip_header(r).strip() - - # Now line contains the first data value; this is also the - # smallest value found so far. - smallest = int(line) - for line in r: - line = line.strip() - - # Only process line if it has a valid value. - if line != '-': - value = int(line) - - # Process value; if we find a smaller value, remember it. - if value < smallest: - smallest = value - - return smallest -if __name__ == "__main__": - input_file = open(sys.argv[1], "r") - print smallest_value_skip(input_file) - input_file.close() diff --git a/code/fileproc/read_url.py b/code/fileproc/read_url.py deleted file mode 100755 index 6ed29b7..0000000 --- a/code/fileproc/read_url.py +++ /dev/null @@ -1,7 +0,0 @@ -import urllib -url = "http://www-personal.buseco.monash.edu.au/~hyndman/TSDL/ecology1/hopedale.dat" -web_page = urllib.urlopen(url) -for line in web_page: - line = line.strip() - print line -web_page.close() diff --git a/code/fileproc/sum.py b/code/fileproc/sum.py deleted file mode 100755 index 250f511..0000000 --- a/code/fileproc/sum.py +++ /dev/null @@ -1,16 +0,0 @@ -def sum(input_file, output_filename): - '''Reads the data from open file descriptor input_file, which contains - two floats per line separated by a space. For each line from - input_file, a line is written to the file named output_filename - containing the two floats from the corresponding line of input_file - plus a space and the sum of the two floats.''' - - output_file = open(output_filename, 'w') - - for line in input_file: - operands = line.split() - print 'operands', operands - sum = float(operands[0]) + float(operands[1]) - new_line = line.rstrip() + ' ' + str(sum) + '\n' - output_file.write(new_line) - output_file.close() diff --git a/code/fileproc/tsdl.py b/code/fileproc/tsdl.py deleted file mode 100755 index 950d36d..0000000 --- a/code/fileproc/tsdl.py +++ /dev/null @@ -1,29 +0,0 @@ -import sys - -def skip_header(r): - '''Skip the header in reader r, and return the first - real piece of data.''' - - # Read the description line and then the comment lines. - line = r.readline() - line = r.readline() - while line.startswith('#'): - line = r.readline() - # Now line contains the first real piece of data. - return line - -def process_file(r): - '''Read and print open reader r.''' - - # Find the first piece of data. - line = skip_header(r).strip() - print line - # Read the rest of the data. - for line in r: - line = line.strip() - print line - -if __name__ == "__main__": - input_file = open(sys.argv[1], 'r') - process_file(input_file) - input_file.close() \ No newline at end of file diff --git a/code/fileproc/write.py b/code/fileproc/write.py deleted file mode 100755 index 88117ec..0000000 --- a/code/fileproc/write.py +++ /dev/null @@ -1,3 +0,0 @@ -output_file = open("test.txt", "w") -output_file.write("Computer Science") -output_file.close() \ No newline at end of file diff --git a/code/gui/checkbutton.py b/code/gui/checkbutton.py deleted file mode 100755 index 631432b..0000000 --- a/code/gui/checkbutton.py +++ /dev/null @@ -1,24 +0,0 @@ -from Tkinter import * - -window = Tk() -frame = Frame(window) -frame.pack() -red = IntVar() -green = IntVar() -blue = IntVar() - -for (name, var) in (('R', red), ('G', green), ('B', blue)): - check = Checkbutton(frame, text=name, variable=var) - check.pack(side='left') -def recolor(widget, r, g, b): - color = '#' - for var in (r, g, b): - color += 'FF' if var.get() else '00' - widget.config(bg=color) - -label = Label(frame, text='[ ]') -button = Button(frame, text='update', - command=lambda: recolor(label, red, green, blue)) -button.pack(side='left') -label.pack(side='left') -window.mainloop() diff --git a/code/gui/color.py b/code/gui/color.py deleted file mode 100755 index 55fa1b4..0000000 --- a/code/gui/color.py +++ /dev/null @@ -1,5 +0,0 @@ -from Tkinter import * -window = Tk() -button = Label(window, text="Hello", bg="green", fg="white") -button.pack() -window.mainloop() diff --git a/code/gui/colorpicker.py b/code/gui/colorpicker.py deleted file mode 100755 index 83ac075..0000000 --- a/code/gui/colorpicker.py +++ /dev/null @@ -1,32 +0,0 @@ -from Tkinter import * -def change(widget, colors): - '''Update the foreground color of a widget to show the RGB color value - stored in a dictionary with keys 'red', 'green', and 'blue'. Does - *not* check the color value. - ''' - new_val = '#' - for name in ('red', 'green', 'blue'): - new_val += colors[name].get() - widget['bg'] = new_val -# Create the application. -window = Tk() -frame = Frame(window) -frame.pack() -# Set up text entry widgets for red, green, and blue, storing the -# associated variables in a dictionary for later use. -colors = {} -for (name, col) in (('red', '#FF0000'), - ('green', '#00FF00'), - ('blue', '#0000FF')): - colors[name] = StringVar() - colors[name].set('00') - entry = Entry(frame, textvariable=colors[name], bg=col, fg="white") - entry.pack() -# Display the current color. -current = Label(frame, text=' ', bg='#FFFFFF') -current.pack() -# Give the user a way to trigger a color update. -update = Button(frame, text='Update', command=lambda: change(current, colors)) -update.pack() -# Run the application. -mainloop() diff --git a/code/gui/entry.py b/code/gui/entry.py deleted file mode 100755 index bd9febd..0000000 --- a/code/gui/entry.py +++ /dev/null @@ -1,13 +0,0 @@ -from Tkinter import * - -window = Tk() - -frame = Frame(window) -frame.pack() -var = StringVar() -label = Label(frame, textvariable=var) -label.pack() -entry = Entry(frame, textvariable=var) -entry.pack() - -window.mainloop() diff --git a/code/gui/font.py b/code/gui/font.py deleted file mode 100755 index ae50268..0000000 --- a/code/gui/font.py +++ /dev/null @@ -1,6 +0,0 @@ -from Tkinter import * -window = Tk() -button = Button(window, text="Hello", font=("Courier", 14, "bold italic")) -button.pack() -window.mainloop() - diff --git a/code/gui/frame.py b/code/gui/frame.py deleted file mode 100755 index d9f23c8..0000000 --- a/code/gui/frame.py +++ /dev/null @@ -1,12 +0,0 @@ -from Tkinter import * - -window = Tk() -frame = Frame(window) -frame.pack() -first = Label(frame, text="First label") -first.pack() -second = Label(frame, text="Second label") -second.pack() -third = Label(frame, text="Third label") -third.pack() -window.mainloop() diff --git a/code/gui/frame2.py b/code/gui/frame2.py deleted file mode 100755 index d88b09d..0000000 --- a/code/gui/frame2.py +++ /dev/null @@ -1,12 +0,0 @@ -window = Tk() -frame = Frame(window) -frame.pack() -frame2 = Frame(window, borderwidth=4, relief=GROOVE) -frame2.pack() -first = Label(frame, text="First label") -first.pack() -second = Label(frame2, text="Second label") -second.pack() -third = Label(frame2, text="Third label") -third.pack() -window.mainloop() diff --git a/code/gui/getwindow.py b/code/gui/getwindow.py deleted file mode 100755 index eced624..0000000 --- a/code/gui/getwindow.py +++ /dev/null @@ -1 +0,0 @@ -window = Tk() diff --git a/code/gui/grid.py b/code/gui/grid.py deleted file mode 100755 index 3400b05..0000000 --- a/code/gui/grid.py +++ /dev/null @@ -1,9 +0,0 @@ -from Tkinter import * -window = Tk() -frame = Frame(window) -frame.pack() -label = Label(frame, text="Name:") -label.grid(row=0, column=0) -entry = Entry(frame) -entry.grid(row=1, column=1) -window.mainloop() diff --git a/code/gui/import.py b/code/gui/import.py deleted file mode 100755 index b74fdad..0000000 --- a/code/gui/import.py +++ /dev/null @@ -1 +0,0 @@ -from Tkinter import * diff --git a/code/gui/label-dict.py b/code/gui/label-dict.py deleted file mode 100755 index 4946afe..0000000 --- a/code/gui/label-dict.py +++ /dev/null @@ -1,8 +0,0 @@ -from Tkinter import * -import time - -window = Tk() -label = Label(window, text="First label.") -label.pack() -time.sleep(2) -label.config(text="Second label.") \ No newline at end of file diff --git a/code/gui/label-variable.py b/code/gui/label-variable.py deleted file mode 100755 index 365a339..0000000 --- a/code/gui/label-variable.py +++ /dev/null @@ -1,7 +0,0 @@ -from Tkinter import * -window = Tk() -data = StringVar() -data.set("Data to display") -label = Label(window, textvariable=data) -label.pack() -window.mainloop() \ No newline at end of file diff --git a/code/gui/label.py b/code/gui/label.py deleted file mode 100755 index dac99bb..0000000 --- a/code/gui/label.py +++ /dev/null @@ -1,4 +0,0 @@ -from Tkinter import * -window = Tk() -label = Label(window, text="This is our label.") -label.pack() diff --git a/code/gui/lambda_1.py b/code/gui/lambda_1.py deleted file mode 100755 index f53dd58..0000000 --- a/code/gui/lambda_1.py +++ /dev/null @@ -1,4 +0,0 @@ ->>> lambda: 3 - at 0x00A89B30> ->>> (lambda: 3)() -3 diff --git a/code/gui/lambda_2.py b/code/gui/lambda_2.py deleted file mode 100755 index d033eb9..0000000 --- a/code/gui/lambda_2.py +++ /dev/null @@ -1,5 +0,0 @@ ->>> def f(): -... return 3 -... ->>> f() -3 diff --git a/code/gui/lambda_3.py b/code/gui/lambda_3.py deleted file mode 100755 index 14a59f6..0000000 --- a/code/gui/lambda_3.py +++ /dev/null @@ -1,3 +0,0 @@ ->>> f = lambda(): 3 ->>> f() -3 diff --git a/code/gui/lambda_4.py b/code/gui/lambda_4.py deleted file mode 100755 index 0f1b88e..0000000 --- a/code/gui/lambda_4.py +++ /dev/null @@ -1,2 +0,0 @@ ->>> (lambda x: 2 * x)(3) -6 diff --git a/code/gui/menu.py b/code/gui/menu.py deleted file mode 100755 index d2c7027..0000000 --- a/code/gui/menu.py +++ /dev/null @@ -1,29 +0,0 @@ -from Tkinter import * -import tkFileDialog as dialog - -def save(root, text): - data = text.get('0.0', END) - filename = dialog.asksaveasfilename( - parent=root, - filetypes=[('Text', '*.txt')], - title='Save as...') - writer = open(filename, 'w') - writer.write(data) - writer.close() - -def quit(root): - root.destroy() - -window = Tk() -text = Text(window) -text.pack() - -menubar = Menu(window) -filemenu = Menu(menubar) -filemenu.add_command(label='Save', command=lambda : save(window, text)) -filemenu.add_command(label='Quit', command=lambda : quit(window)) - -menubar.add_cascade(label = 'File', menu=filemenu) -window.config(menu=menubar) - -window.mainloop() diff --git a/code/gui/mvc.py b/code/gui/mvc.py deleted file mode 100755 index 93baf39..0000000 --- a/code/gui/mvc.py +++ /dev/null @@ -1,26 +0,0 @@ -# Initialization. -from Tkinter import * - -# The controller. -def click(): - counter.set(counter.get() + 1) - -if __name__ == '__main__': - # More initialization. - window = Tk() - - # The model. - counter = IntVar() - counter.set(0) - - # The views. - frame = Frame(window) - frame.pack() - - button = Button(frame, text="Click", command=click) - button.pack() - - label = Label(frame, textvariable=counter) - label.pack() - - window.mainloop() diff --git a/code/gui/mvc2.py b/code/gui/mvc2.py deleted file mode 100755 index 0e0e528..0000000 --- a/code/gui/mvc2.py +++ /dev/null @@ -1,23 +0,0 @@ -# Initialization. -from Tkinter import * -window = Tk() -# The model. -counter = IntVar() -counter.set(0) - -# Two controllers -def click_up(): - counter.set(counter.get() + 1) -def click_down(): - counter.set(counter.get() - 1) - -# The views. -frame = Frame(window) -frame.pack() -button = Button(frame, text="Up", command=click_up) -button.pack() -button = Button(frame, text="Down", command=click_down) -button.pack() -label = Label(frame, textvariable=counter) -label.pack() -window.mainloop() \ No newline at end of file diff --git a/code/gui/mvc3.py b/code/gui/mvc3.py deleted file mode 100755 index 0ed2dfe..0000000 --- a/code/gui/mvc3.py +++ /dev/null @@ -1,26 +0,0 @@ -# Initialization. -from Tkinter import * -window = Tk() - -# The model. -counter = IntVar() -counter.set(0) - -# General controller -def click(var, value): - var.set(var.get() + value) - -# The views. -frame = Frame(window) -frame.pack() - -button = Button(frame, text="Up", command=lambda: click(counter, 1)) -button.pack() - -button = Button(frame, text="Down", command=lambda: click(counter, -1)) -button.pack() - -label = Label(frame, textvariable=counter) -label.pack() - -window.mainloop() diff --git a/code/gui/mvc_one_func.py b/code/gui/mvc_one_func.py deleted file mode 100755 index 5fbf018..0000000 --- a/code/gui/mvc_one_func.py +++ /dev/null @@ -1,6 +0,0 @@ -# The model. -counter = IntVar() -counter.set(0) -# One controller with parameters. -def click(variable, value): - variable.set(variable.get() + value) diff --git a/code/gui/mvc_wrapper_func.py b/code/gui/mvc_wrapper_func.py deleted file mode 100755 index 923c598..0000000 --- a/code/gui/mvc_wrapper_func.py +++ /dev/null @@ -1,4 +0,0 @@ -def click_up(): - click(counter, 1) -def click_down(): - click(counter, -1) diff --git a/code/gui/oogui.py b/code/gui/oogui.py deleted file mode 100755 index 0e68ab9..0000000 --- a/code/gui/oogui.py +++ /dev/null @@ -1,38 +0,0 @@ -from Tkinter import * - -class Counter: - '''A simple counter GUI using object-oriented programming.''' - def __init__(self, parent): - '''Create the GUI.''' - # Framework. - self.parent = parent - self.frame = Frame(parent) - self.frame.pack() - - # Model. - self.state = IntVar() - self.state.set(1) - - # Label displaying current state. - self.label = Label(self.frame, textvariable=self.state) - self.label.pack() - - # Buttons to control application. - self.up = Button(self.frame, text='up', command=self.upClick) - self.up.pack(side='left') - - self.right = Button(self.frame, text='quit', command=self.quitClick) - self.right.pack(side='left') - - def upClick(self): - '''Handle click on 'up' button.''' - self.state.set(self.state.get() + 1) - - def quitClick(self): - '''Handle click on 'quit' button.''' - self.parent.destroy() - -if __name__ == '__main__': - window = Tk() - myapp = Counter(window) - window.mainloop() diff --git a/code/gui/side.py b/code/gui/side.py deleted file mode 100755 index 8fae6f6..0000000 --- a/code/gui/side.py +++ /dev/null @@ -1,9 +0,0 @@ -from Tkinter import * -window = Tk() -frame = Frame(window) -frame.pack() -label = Label(frame, text="Name") -label.pack(side="left") -entry = Entry(frame) -entry.pack(side="left") -window.mainloop() diff --git a/code/gui/text.py b/code/gui/text.py deleted file mode 100755 index 3722313..0000000 --- a/code/gui/text.py +++ /dev/null @@ -1,16 +0,0 @@ -from Tkinter import * - -def cross(text): - text.insert(INSERT, 'X') - -window = Tk() -frame = Frame(window) -frame.pack() - -text = Text(frame, height=3, width=10) -text.pack() - -button = Button(frame, text="Add", command=lambda: cross(text)) -button.pack() - -window.mainloop() diff --git a/code/install/PyGraphics 2.0.pkg/.svn/entries b/code/install/PyGraphics 2.0.pkg/.svn/entries deleted file mode 100755 index f80b93c..0000000 --- a/code/install/PyGraphics 2.0.pkg/.svn/entries +++ /dev/null @@ -1,23 +0,0 @@ -8 - -dir -0 -https://pygraphics.googlecode.com/svn/trunk/MacInstallers/PyGraphics%202.0.pkg -https://pygraphics.googlecode.com/svn -add - - - - - - - -svn:special svn:externals svn:needs-lock - -Contents -dir - - - -add - diff --git a/code/install/PyGraphics 2.0.pkg/.svn/format b/code/install/PyGraphics 2.0.pkg/.svn/format deleted file mode 100755 index 45a4fb7..0000000 --- a/code/install/PyGraphics 2.0.pkg/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/code/install/PyGraphics 2.0.pkg/.svn/lock b/code/install/PyGraphics 2.0.pkg/.svn/lock deleted file mode 100755 index e69de29..0000000 diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/entries b/code/install/PyGraphics 2.0.pkg/Contents/.svn/entries deleted file mode 100755 index 33316b2..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/entries +++ /dev/null @@ -1,79 +0,0 @@ -8 - -dir -0 -https://pygraphics.googlecode.com/svn/trunk/MacInstallers/PyGraphics%202.0.pkg/Contents -https://pygraphics.googlecode.com/svn -add - - - - - - - -svn:special svn:externals svn:needs-lock - -Info.plist -file - - - -add - - - - - -has-props -has-prop-mods - -Archive.pax.gz -file - - - -add - - - - - -has-props -has-prop-mods - -Resources -dir - - - -add - -Archive.bom -file - - - -add - - - - - -has-props -has-prop-mods - -PkgInfo -file - - - -add - - - - - -has-props -has-prop-mods - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/format b/code/install/PyGraphics 2.0.pkg/Contents/.svn/format deleted file mode 100755 index 45a4fb7..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/lock b/code/install/PyGraphics 2.0.pkg/Contents/.svn/lock deleted file mode 100755 index e69de29..0000000 diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Archive.bom.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Archive.bom.svn-work deleted file mode 100755 index dbc918b..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Archive.bom.svn-work +++ /dev/null @@ -1,9 +0,0 @@ -K 14 -svn:executable -V 1 -* -K 13 -svn:mime-type -V 24 -application/octet-stream -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Archive.pax.gz.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Archive.pax.gz.svn-work deleted file mode 100755 index dbc918b..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Archive.pax.gz.svn-work +++ /dev/null @@ -1,9 +0,0 @@ -K 14 -svn:executable -V 1 -* -K 13 -svn:mime-type -V 24 -application/octet-stream -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Info.plist.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Info.plist.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/Info.plist.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/PkgInfo.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/PkgInfo.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/props/PkgInfo.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Archive.bom.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Archive.bom.svn-work deleted file mode 100755 index dbc918b..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Archive.bom.svn-work +++ /dev/null @@ -1,9 +0,0 @@ -K 14 -svn:executable -V 1 -* -K 13 -svn:mime-type -V 24 -application/octet-stream -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Archive.pax.gz.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Archive.pax.gz.svn-work deleted file mode 100755 index dbc918b..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Archive.pax.gz.svn-work +++ /dev/null @@ -1,9 +0,0 @@ -K 14 -svn:executable -V 1 -* -K 13 -svn:mime-type -V 24 -application/octet-stream -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Info.plist.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Info.plist.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/Info.plist.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/PkgInfo.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/PkgInfo.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/props/PkgInfo.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Archive.bom.svn-base b/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Archive.bom.svn-base deleted file mode 100755 index 9afc0e2..0000000 Binary files a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Archive.bom.svn-base and /dev/null differ diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Archive.pax.gz.svn-base b/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Archive.pax.gz.svn-base deleted file mode 100755 index 5719391..0000000 Binary files a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Archive.pax.gz.svn-base and /dev/null differ diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Info.plist.svn-base b/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Info.plist.svn-base deleted file mode 100755 index 68c35e7..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/Info.plist.svn-base +++ /dev/null @@ -1,46 +0,0 @@ - - - - - CFBundleIdentifier - com.uoftcompsci.pygraphics2 - CFBundleName - PyGraphics 2.0 - CFBundleShortVersionString - 2.0 - IFMajorVersion - 2 - IFMinorVersion - 0 - IFPkgFlagAllowBackRev - - IFPkgFlagAuthorizationAction - RootAuthorization - IFPkgFlagBackgroundAlignment - center - IFPkgFlagBackgroundScaling - none - IFPkgFlagDefaultLocation - /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages - IFPkgFlagFollowLinks - - IFPkgFlagInstallFat - - IFPkgFlagInstalledSize - 188 - IFPkgFlagIsRequired - - IFPkgFlagOverwritePermissions - - IFPkgFlagRelocatable - - IFPkgFlagRestartAction - None - IFPkgFlagRootVolumeOnly - - IFPkgFlagUpdateInstalledLanguages - - IFPkgFormatVersion - 0.10000000149011612 - - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/PkgInfo.svn-base b/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/PkgInfo.svn-base deleted file mode 100755 index 28684a2..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/.svn/tmp/text-base/PkgInfo.svn-base +++ /dev/null @@ -1 +0,0 @@ -pkmkrpkg1 \ No newline at end of file diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Archive.bom b/code/install/PyGraphics 2.0.pkg/Contents/Archive.bom deleted file mode 100755 index 9afc0e2..0000000 Binary files a/code/install/PyGraphics 2.0.pkg/Contents/Archive.bom and /dev/null differ diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Archive.pax.gz b/code/install/PyGraphics 2.0.pkg/Contents/Archive.pax.gz deleted file mode 100755 index 5719391..0000000 Binary files a/code/install/PyGraphics 2.0.pkg/Contents/Archive.pax.gz and /dev/null differ diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Info.plist b/code/install/PyGraphics 2.0.pkg/Contents/Info.plist deleted file mode 100755 index 68c35e7..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Info.plist +++ /dev/null @@ -1,46 +0,0 @@ - - - - - CFBundleIdentifier - com.uoftcompsci.pygraphics2 - CFBundleName - PyGraphics 2.0 - CFBundleShortVersionString - 2.0 - IFMajorVersion - 2 - IFMinorVersion - 0 - IFPkgFlagAllowBackRev - - IFPkgFlagAuthorizationAction - RootAuthorization - IFPkgFlagBackgroundAlignment - center - IFPkgFlagBackgroundScaling - none - IFPkgFlagDefaultLocation - /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages - IFPkgFlagFollowLinks - - IFPkgFlagInstallFat - - IFPkgFlagInstalledSize - 188 - IFPkgFlagIsRequired - - IFPkgFlagOverwritePermissions - - IFPkgFlagRelocatable - - IFPkgFlagRestartAction - None - IFPkgFlagRootVolumeOnly - - IFPkgFlagUpdateInstalledLanguages - - IFPkgFormatVersion - 0.10000000149011612 - - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/PkgInfo b/code/install/PyGraphics 2.0.pkg/Contents/PkgInfo deleted file mode 100755 index 28684a2..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/PkgInfo +++ /dev/null @@ -1 +0,0 @@ -pkmkrpkg1 \ No newline at end of file diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/entries b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/entries deleted file mode 100755 index 22f95f3..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/entries +++ /dev/null @@ -1,79 +0,0 @@ -8 - -dir -0 -https://pygraphics.googlecode.com/svn/trunk/MacInstallers/PyGraphics%202.0.pkg/Contents/Resources -https://pygraphics.googlecode.com/svn -add - - - - - - - -svn:special svn:externals svn:needs-lock - -background.tif -file - - - -add - - - - - -has-props -has-prop-mods - -package_version -file - - - -add - - - - - -has-props -has-prop-mods - -Welcome.rtf -file - - - -add - - - - - -has-props -has-prop-mods - -en.lproj -dir - - - -add - -Description.plist -file - - - -add - - - - - -has-props -has-prop-mods - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/format b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/format deleted file mode 100755 index 45a4fb7..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/lock b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/lock deleted file mode 100755 index e69de29..0000000 diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/Description.plist.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/Description.plist.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/Description.plist.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/Welcome.rtf.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/Welcome.rtf.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/Welcome.rtf.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/background.tif.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/background.tif.svn-work deleted file mode 100755 index dbc918b..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/background.tif.svn-work +++ /dev/null @@ -1,9 +0,0 @@ -K 14 -svn:executable -V 1 -* -K 13 -svn:mime-type -V 24 -application/octet-stream -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/package_version.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/package_version.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/props/package_version.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/Description.plist.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/Description.plist.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/Description.plist.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/Welcome.rtf.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/Welcome.rtf.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/Welcome.rtf.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/background.tif.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/background.tif.svn-work deleted file mode 100755 index dbc918b..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/background.tif.svn-work +++ /dev/null @@ -1,9 +0,0 @@ -K 14 -svn:executable -V 1 -* -K 13 -svn:mime-type -V 24 -application/octet-stream -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/package_version.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/package_version.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/props/package_version.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/text-base/Description.plist.svn-base b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/text-base/Description.plist.svn-base deleted file mode 100755 index 4031873..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/text-base/Description.plist.svn-base +++ /dev/null @@ -1,10 +0,0 @@ - - - - - IFPkgDescriptionTitle - PyGraphics - IFPkgDescriptionVersion - 2.0 - - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/text-base/package_version.svn-base b/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/text-base/package_version.svn-base deleted file mode 100755 index c052336..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/.svn/tmp/text-base/package_version.svn-base +++ /dev/null @@ -1,2 +0,0 @@ -major: 1 -minor: 0 \ No newline at end of file diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/Description.plist b/code/install/PyGraphics 2.0.pkg/Contents/Resources/Description.plist deleted file mode 100755 index 4031873..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/Description.plist +++ /dev/null @@ -1,10 +0,0 @@ - - - - - IFPkgDescriptionTitle - PyGraphics - IFPkgDescriptionVersion - 2.0 - - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/Welcome.rtf b/code/install/PyGraphics 2.0.pkg/Contents/Resources/Welcome.rtf deleted file mode 100755 index cb71d22..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/Welcome.rtf +++ /dev/null @@ -1,21 +0,0 @@ -{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf330 -{\fonttbl\f0\fswiss\fcharset0 Helvetica;} -{\colortbl;\red255\green255\blue255;} -\paperw11900\paperh16840\margl1440\margr1440\vieww9000\viewh8400\viewkind0 -\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural - -\f0\fs24 \cf0 This will install -\b PyGraphics 2.0 -\b0 for -\b Python 2.5 -\b0 \ -\ -PyGraphics provides a set of easy-to-use procedural media manipulation tools and is intended for new programmers. It is based on a Jython library developed by Mark Guzdial at Georgia Tech, and has been further developed into a Cpython library by Jen Campbell, Paul Gries, Leo Kaliazine, Chris Maddison, and Hardeep Singh.\ -\ -Make sure the following are already installed, we will not check for you:\ -\ - -\b Python 2.5\ -Python Imaging Library 1.1.6\ -Pygame 1.8.0\ -NumPy 1.1.0} \ No newline at end of file diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/background.tif b/code/install/PyGraphics 2.0.pkg/Contents/Resources/background.tif deleted file mode 100755 index d6b92dc..0000000 Binary files a/code/install/PyGraphics 2.0.pkg/Contents/Resources/background.tif and /dev/null differ diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/entries b/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/entries deleted file mode 100755 index c580c35..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/entries +++ /dev/null @@ -1,30 +0,0 @@ -8 - -dir -0 -https://pygraphics.googlecode.com/svn/trunk/MacInstallers/PyGraphics%202.0.pkg/Contents/Resources/en.lproj -https://pygraphics.googlecode.com/svn -add - - - - - - - -svn:special svn:externals svn:needs-lock - -Description.plist -file - - - -add - - - - - -has-props -has-prop-mods - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/format b/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/format deleted file mode 100755 index 45a4fb7..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/lock b/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/lock deleted file mode 100755 index e69de29..0000000 diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/props/Description.plist.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/props/Description.plist.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/props/Description.plist.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/tmp/props/Description.plist.svn-work b/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/tmp/props/Description.plist.svn-work deleted file mode 100755 index 869ac71..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/tmp/props/Description.plist.svn-work +++ /dev/null @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/tmp/text-base/Description.plist.svn-base b/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/tmp/text-base/Description.plist.svn-base deleted file mode 100755 index b3cff76..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/.svn/tmp/text-base/Description.plist.svn-base +++ /dev/null @@ -1,12 +0,0 @@ - - - - - IFPkgDescriptionDescription - - IFPkgDescriptionTitle - PyGraphics - IFPkgDescriptionVersion - 2.0 - - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/Description.plist b/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/Description.plist deleted file mode 100755 index b3cff76..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/en.lproj/Description.plist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - IFPkgDescriptionDescription - - IFPkgDescriptionTitle - PyGraphics - IFPkgDescriptionVersion - 2.0 - - diff --git a/code/install/PyGraphics 2.0.pkg/Contents/Resources/package_version b/code/install/PyGraphics 2.0.pkg/Contents/Resources/package_version deleted file mode 100755 index c052336..0000000 --- a/code/install/PyGraphics 2.0.pkg/Contents/Resources/package_version +++ /dev/null @@ -1,2 +0,0 @@ -major: 1 -minor: 0 \ No newline at end of file diff --git a/code/install/PyGraphics-2.0.win32.exe b/code/install/PyGraphics-2.0.win32.exe deleted file mode 100755 index 0098022..0000000 Binary files a/code/install/PyGraphics-2.0.win32.exe and /dev/null differ diff --git a/code/install/PyGraphics.tgz b/code/install/PyGraphics.tgz deleted file mode 100755 index 0c0a868..0000000 Binary files a/code/install/PyGraphics.tgz and /dev/null differ diff --git a/code/install/PyGraphics2.0.pkg.zip b/code/install/PyGraphics2.0.pkg.zip deleted file mode 100755 index ac8e82a..0000000 Binary files a/code/install/PyGraphics2.0.pkg.zip and /dev/null differ diff --git a/code/install/index.html b/code/install/index.html deleted file mode 100755 index 1eac492..0000000 --- a/code/install/index.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - Practical Programming: installation instructions - - - -
-

- Practical Programming: installation instructions -

-
-
-

- PyGraphics provides a set of easy-to-use media-manipulation tools written in Python. Some of the examples in the book make use of it. If you want to use the image manipulation examples from the book, you should use Python 2.5 because some of the libraries that our code relies on have not yet been updated to work with Python 2.6. -

-

- Python 3.0 has several changes that are not compatible with the code in this book. -

What to Install -

- All of these instructions refer to a PyGraphics package that is included in the code distribution on the Practical Programming website for this book. -

-
    -
  • - Mac OS X: -
      -
    • - Python 2.5 -
    • -
    • X11 (from 'Optional programs' on your Mac OS X install disc); this may already be installed. -
    • -
    • - Wing IDE 101 -
    • -
    • - Python Imaging Library 1.1.6 -
    • -
    • - PyObjC 1.4 -
    • -
    • - Pygame 1.8.1 -
    • -
    • - NumPy 1.3 -
    • -
    • Unzip PyGraphics2.0.pkg.zip from the install directory in the code for the book and double-click to perform the installation of the media tools. -
    • -
    • nose (you won't need this for a few chapters) -
        -
      • Step 1: Install setuptools -
      • -
      • Step 2: Run Terminal.app (in /Applications/Utilities) -
      • -
      • Step 3: For this step to work, you must be connected to the internet. In a Terminal window, type:
        - easy_install nose
        -
      • -
      -
    • -
    -
  • -
  • - Windows: - -
  • -
-
    -
  • - Ubuntu/Debian: -
      -
    • - sudo apt-get install python-imaging python-imaging-tk python-pygame python-numpy python-setuptools -
    • -
    • Install PyGraphics 2.0 from the install directory in the code for the book:
      - tar zxvf PyGraphics.tgz
      - cd to the cpython subdirectory
      - sudo python setup.py install -
    • -
    • Install nose: sudo easy_install nose -
    • -
    -
  • -
-
- - diff --git a/code/lists/add_list_str.cmd b/code/lists/add_list_str.cmd deleted file mode 100755 index 87491cf..0000000 --- a/code/lists/add_list_str.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> ['H', 'He', 'Li'] + 'Be' -Traceback (most recent call last): - File "", line 1, in -TypeError: can only concatenate list (not "str") to list diff --git a/code/lists/alias_parameters.cmd b/code/lists/alias_parameters.cmd deleted file mode 100755 index d2052b4..0000000 --- a/code/lists/alias_parameters.cmd +++ /dev/null @@ -1,11 +0,0 @@ ->>> def sort_and_reverse(L): -... '''Return list L sorted and reversed.''' -... L.sort() -... L.reverse() -... return L -... ->>> celegans_markers = ['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Lvl'] ->>> sort_and_reverse(celegans_markers) -['Unc', 'Lvl', 'Lon', 'Him', 'Emb', 'Dpy'] ->>> celegans_markers -['Unc', 'Lvl', 'Lon', 'Him', 'Emb', 'Dpy'] diff --git a/code/lists/celegans.cmd b/code/lists/celegans.cmd deleted file mode 100755 index c3162d8..0000000 --- a/code/lists/celegans.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> celegans_markers = ['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Sma'] ->>> celegans_markers -['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Sma'] diff --git a/code/lists/celegans1.cmd b/code/lists/celegans1.cmd deleted file mode 100755 index a30d241..0000000 --- a/code/lists/celegans1.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> celegans_markers = ['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Sma'] ->>> useful_markers = celegans_markers[0:4] \ No newline at end of file diff --git a/code/lists/celegans2.cmd b/code/lists/celegans2.cmd deleted file mode 100755 index f0644b5..0000000 --- a/code/lists/celegans2.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> celegans_markers = ['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Sma'] ->>> celegans_markers[:4] -['Emb', 'Him', 'Unc', 'Lon'] ->>> celegans_markers[4:] -['Dpy', 'Sma'] diff --git a/code/lists/celegans3.cmd b/code/lists/celegans3.cmd deleted file mode 100755 index aa91e73..0000000 --- a/code/lists/celegans3.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> celegans_markers = ['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Sma'] ->>> celegans_copy = celegans_markers[:] ->>> celegans_markers[5] = 'Lvl' ->>> celegans_markers -['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Lvl'] ->>> celegans_copy -['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Sma'] diff --git a/code/lists/celegans4.cmd b/code/lists/celegans4.cmd deleted file mode 100755 index f718aaa..0000000 --- a/code/lists/celegans4.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> celegans_markers = ['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Sma'] ->>> celegans_copy = celegans_markers ->>> celegans_markers[5] = 'Lvl' ->>> celegans_markers -['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Lvl'] ->>> celegans_copy -['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Lvl'] diff --git a/code/lists/colors.cmd b/code/lists/colors.cmd deleted file mode 100755 index eefb6cc..0000000 --- a/code/lists/colors.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> colors = 'red orange green black blue'.split() ->>> colors.append('purple') ->>> colors -['red', 'orange', 'green', 'black', 'blue', 'purple'] ->>> colors.insert(2, 'yellow') ->>> colors -['red', 'orange', 'yellow', 'green', 'black', 'blue', 'black', 'purple'] ->>> colors.remove('black') ->>> colors -['red', 'orange', 'yellow', 'green', 'blue', 'purple'] diff --git a/code/lists/colors2.cmd b/code/lists/colors2.cmd deleted file mode 100755 index 837e5d1..0000000 --- a/code/lists/colors2.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> colors = 'red orange yellow green blue purple'.split() ->>> colors -['blue', 'green', 'orange', 'purple', 'red', 'yellow'] ->>> sorted_colors = colors.sort() ->>> print sorted_colors -None diff --git a/code/lists/concat_lists.cmd b/code/lists/concat_lists.cmd deleted file mode 100755 index 97de0f3..0000000 --- a/code/lists/concat_lists.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> original = ['H', 'He', 'Li'] ->>> final = original + ['Be'] ->>> final -['H', 'He', 'Li', 'Be'] diff --git a/code/lists/data.txt b/code/lists/data.txt deleted file mode 100755 index 6b75118..0000000 --- a/code/lists/data.txt +++ /dev/null @@ -1,4 +0,0 @@ -Mercury -Venus -Earth -Mars diff --git a/code/lists/fileinputloop.cmd b/code/lists/fileinputloop.cmd deleted file mode 100755 index 97cd634..0000000 --- a/code/lists/fileinputloop.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> data = open('data.txt', 'r') ->>> for line in data: -... print len(line) -... -8 -6 -6 -5 diff --git a/code/lists/fileinputloop2.cmd b/code/lists/fileinputloop2.cmd deleted file mode 100755 index 4c33081..0000000 --- a/code/lists/fileinputloop2.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> data = open('data.txt', 'r') ->>> for line in data: -... print len(line.strip()) -... - -7 -5 -5 -4 diff --git a/code/lists/fileinputloop_strip.cmd b/code/lists/fileinputloop_strip.cmd deleted file mode 100755 index 0e29cfe..0000000 --- a/code/lists/fileinputloop_strip.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> file = open('data.txt', 'r') ->>> for line in file: -... line = line.strip() -... print len(line) -... -7 -5 -5 -4 diff --git a/code/lists/krypton1.cmd b/code/lists/krypton1.cmd deleted file mode 100755 index 6c30077..0000000 --- a/code/lists/krypton1.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> krypton = ['Krypton', 'Kr', -157.2, -153.4] ->>> krypton[1] -'Kr' ->>> krypton[2] --157.19999999999999 diff --git a/code/lists/life0.cmd b/code/lists/life0.cmd deleted file mode 100755 index fa46cd6..0000000 --- a/code/lists/life0.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> life = [['Canada', 76.5], ['United States', 75.5], ['Mexico', 72.0]] ->>> life[0] -['Canada', 76.5] ->>> life[1] -['United States', 75.5] ->>> life[2] -['Mexico', 72.0] diff --git a/code/lists/life1.cmd b/code/lists/life1.cmd deleted file mode 100755 index 19cc955..0000000 --- a/code/lists/life1.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> life = [['Canada', 76.5], ['United States', 75.5], ['Mexico', 72.0]] ->>> life[1] -['United States', 75.5] ->>> life[1][0] -'United States' ->>> life[1][1] -75.5 diff --git a/code/lists/life2.cmd b/code/lists/life2.cmd deleted file mode 100755 index a900880..0000000 --- a/code/lists/life2.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> life = [['Canada', 76.5], ['United States', 75.5], ['Mexico', 72.0]] ->>> canada = life[0] ->>> canada -['Canada', 76.5] ->>> canada[0] -'Canada' ->>> canada[1] -76.5 diff --git a/code/lists/life3.cmd b/code/lists/life3.cmd deleted file mode 100755 index 7d1ba51..0000000 --- a/code/lists/life3.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> life = [['Canada', 76.5], ['United States', 75.5], ['Mexico', 72.0]] ->>> canada = life[0] ->>> canada[1] = 80.0 ->>> canada -['Canada', 80.0] ->>> life -[['Canada', 80.0], ['United States', 75.5], ['Mexico', 72.0]] diff --git a/code/lists/life4.cmd b/code/lists/life4.cmd deleted file mode 100755 index 5650cdc..0000000 --- a/code/lists/life4.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> life = (['Canada', 76.5], ['United States', 75.5], ['Mexico', 72.0]) ->>> life[0] = life[1] -Traceback (most recent call last): - File "", line 1, in ? -TypeError: object does not support item assignment diff --git a/code/lists/life5.cmd b/code/lists/life5.cmd deleted file mode 100755 index 64cda57..0000000 --- a/code/lists/life5.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> life = (['Canada', 76.5], ['United States', 75.5], ['Mexico', 72.0]) ->>> life[0][1] = 80.0 ->>> life -(['Canada', 80.0], ['United States', 75.5], ['Mexico', 72.0]) diff --git a/code/lists/lifelist.py b/code/lists/lifelist.py deleted file mode 100755 index 199fc23..0000000 --- a/code/lists/lifelist.py +++ /dev/null @@ -1 +0,0 @@ -[['Canada', 76.5], ['United States', 75.5], ['Mexico', 72.0]] diff --git a/code/lists/mult_lists.cmd b/code/lists/mult_lists.cmd deleted file mode 100755 index e8551c5..0000000 --- a/code/lists/mult_lists.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> metals = 'Fe Ni'.split() ->>> metals * 3 -['Fe', 'Ni', 'Fe', 'Ni', 'Fe', 'Ni'] diff --git a/code/lists/multiplication_out.txt b/code/lists/multiplication_out.txt deleted file mode 100755 index 7610bdc..0000000 --- a/code/lists/multiplication_out.txt +++ /dev/null @@ -1,8 +0,0 @@ ->>> from multiplication_table import * ->>> print_table() - 1 2 3 4 5 -1 1 2 3 4 5 -2 2 4 6 8 10 -3 3 6 9 12 15 -4 4 8 12 16 20 -5 5 10 15 20 25 diff --git a/code/lists/multiplication_table.py b/code/lists/multiplication_table.py deleted file mode 100755 index 6dd9ccc..0000000 --- a/code/lists/multiplication_table.py +++ /dev/null @@ -1,13 +0,0 @@ -def print_table(): - '''Print the multiplication table for numbers 1 through 5.''' - numbers = [1, 2, 3, 4, 5] - # Print the header row. - for i in numbers: - print '\t' + str(i), - print # End the header row. - # Print the column number and the contents of the table. - for i in numbers: - print i, - for j in numbers: - print '\t' + str(i * j), - print # End the current row. diff --git a/code/lists/nested_loops.cmd b/code/lists/nested_loops.cmd deleted file mode 100755 index a8639d2..0000000 --- a/code/lists/nested_loops.cmd +++ /dev/null @@ -1,16 +0,0 @@ ->>> outer = ['Li', 'Na', 'K'] ->>> inner = ['F', 'Cl', 'Br'] ->>> for metal in outer: -... for halogen in inner: -... print metal + halogen -... -... -LiF -LiCl -LiBr -NaF -NaCl -NaBr -KF -KCl -KBr diff --git a/code/lists/nobles1.cmd b/code/lists/nobles1.cmd deleted file mode 100755 index b97457e..0000000 --- a/code/lists/nobles1.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> nobles = ['helium', 'none', 'argon', 'krypton', 'xenon', 'radon'] diff --git a/code/lists/nobles2.cmd b/code/lists/nobles2.cmd deleted file mode 100755 index 3d49b5b..0000000 --- a/code/lists/nobles2.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> nobles = ['helium', 'none', 'argon', 'krypton', 'xenon', 'radon'] ->>> nobles[1] = 'neon' ->>> nobles -['helium', 'neon', 'argon', 'krypton', 'xenon', 'radon'] diff --git a/code/lists/none.cmd b/code/lists/none.cmd deleted file mode 100755 index 431da6f..0000000 --- a/code/lists/none.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> x = None ->>> x ->>> print x -None diff --git a/code/lists/open_basic.cmd b/code/lists/open_basic.cmd deleted file mode 100755 index fcf8635..0000000 --- a/code/lists/open_basic.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> file = open("data.txt", "r") diff --git a/code/lists/plu4.cmd b/code/lists/plu4.cmd deleted file mode 100755 index 7653276..0000000 --- a/code/lists/plu4.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> half_lives = [87.74, 24110.0, 6537.0, 14.4, 376000.0] ->>> len(half_lives) -5 ->>> max(half_lives) -376000.0 ->>> min(half_lives) -14.4 ->>> sum(half_lives) -406749.14000000001 diff --git a/code/lists/plu5.cmd b/code/lists/plu5.cmd deleted file mode 100755 index 961a8e8..0000000 --- a/code/lists/plu5.cmd +++ /dev/null @@ -1,14 +0,0 @@ ->>> half_lives = [87.74, 24110.0, 6537.0, 14.4, 376000.0] ->>> i = 2 ->>> i < len(half_lives) -True - ->>> half_lives[i] -6537.0 ->>> j = 5 ->>> j < len(half_lives) -False ->>> half_lives[j] -Traceback (most recent call last): - File "", line 1, in ? -IndexError: list index out of range diff --git a/code/lists/read_lines_range.py b/code/lists/read_lines_range.py deleted file mode 100755 index a3d6aab..0000000 --- a/code/lists/read_lines_range.py +++ /dev/null @@ -1,22 +0,0 @@ -''' Display the lines of data.txt from the given starting line number to the -given end line number. - -Usage: read_lines_range.py start_line end_line ''' - -import sys - -if __name__ == '__main__': - - # get the start and end line numbers - start_line = int(sys.argv[1]) - end_line = int(sys.argv[2]) - - # read the lines of the file and store them in a list - data = open('data.txt', 'r') - data_list = data.readlines() - data.close() - - # display lines within start to end range - for line in data_list[start_line:end_line]: - print line.strip() - \ No newline at end of file diff --git a/code/lists/string_seq.cmd b/code/lists/string_seq.cmd deleted file mode 100755 index 773e683..0000000 --- a/code/lists/string_seq.cmd +++ /dev/null @@ -1,15 +0,0 @@ ->>> rock = 'anthracite' ->>> rock[9] -'e' ->>> rock[0:3] -'ant' ->>> rock[-5:] -'acite' ->>> for character in rock[:5]: -... print character -... -a -n -t -h -r diff --git a/code/lists/strings_immutable.cmd b/code/lists/strings_immutable.cmd deleted file mode 100755 index ce9c50c..0000000 --- a/code/lists/strings_immutable.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> name = 'Darwin' ->>> capitalized = name.upper() ->>> print capitalized -'DARWIN' ->>> print name -'Darwin' diff --git a/code/lists/strip_basic.cmd b/code/lists/strip_basic.cmd deleted file mode 100755 index e996d45..0000000 --- a/code/lists/strip_basic.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> compound = " \n Methyl butanol \n" ->>> print compound - - Methyl butanol - - - ->>> print compound.strip() -Methyl butanol diff --git a/code/lists/sum_of_str.cmd b/code/lists/sum_of_str.cmd deleted file mode 100755 index e8d91d7..0000000 --- a/code/lists/sum_of_str.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> sum(['a', 'b', 'c']) -Traceback (most recent call last): - File "", line 1, in -TypeError: unsupported operand type(s) for +: 'int' and 'str' diff --git a/code/lists/tuples1.cmd b/code/lists/tuples1.cmd deleted file mode 100755 index 5aed5f1..0000000 --- a/code/lists/tuples1.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> bases = ('A', 'C', 'G', 'T') -... for b in bases: -... print b -A -C -G -T diff --git a/code/lists/velocity_loop.cmd b/code/lists/velocity_loop.cmd deleted file mode 100755 index 1ab91c3..0000000 --- a/code/lists/velocity_loop.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> velocities = [0.0, 9.81, 19.62, 29.43] ->>> for v in velocities: -... print "Metric:", v, "m/sec;", -... print "Imperial:", v * 3.28, "ft/sec" -... -Metric: 0.0 m/sec; Imperial: 0.0 ft/sec -Metric: 9.81 m/sec; Imperial: 32.1768 ft/sec -Metric: 19.62 m/sec; Imperial: 64.3536 ft/sec -Metric: 29.43 m/sec; Imperial: 96.5304 ft/sec diff --git a/code/lists/velocity_recycle.cmd b/code/lists/velocity_recycle.cmd deleted file mode 100755 index 5f969d3..0000000 --- a/code/lists/velocity_recycle.cmd +++ /dev/null @@ -1,11 +0,0 @@ ->>> speed = 2 ->>> velocities = [0.0, 9.81, 19.62, 29.43] ->>> for speed in velocities: -... print "Metric:", speed, "m/sec;", -... -Metric: 0.0 m/sec -Metric: 9.81 m/sec -Metric: 19.62 m/sec -Metric: 29.43 m/sec ->>> print "Final:", speed -Final: 29.43 diff --git a/code/lists/whalelist.py b/code/lists/whalelist.py deleted file mode 100755 index 2a7b2fc..0000000 --- a/code/lists/whalelist.py +++ /dev/null @@ -1,2 +0,0 @@ -# Number of whales seen per day -[5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, 7, 1, 3] diff --git a/code/lists/whales1.cmd b/code/lists/whales1.cmd deleted file mode 100755 index de3ab3c..0000000 --- a/code/lists/whales1.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> whales = [5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, 7, 1, 3] ->>> whales -[5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, 7, 1, 3] diff --git a/code/lists/whales2.cmd b/code/lists/whales2.cmd deleted file mode 100755 index d15bada..0000000 --- a/code/lists/whales2.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> whales = [5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, 7, 1, 3] ->>> whales[0] -5 ->>> whales[1] -4 ->>> whales[12] -1 ->>> whales[13] -3 diff --git a/code/lists/whales3.cmd b/code/lists/whales3.cmd deleted file mode 100755 index 54b2144..0000000 --- a/code/lists/whales3.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> whales = [5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, 7, 1, 3] ->>> whales[1001] -Traceback (most recent call last): - File "", line 1, in ? -IndexError: list index out of range diff --git a/code/lists/whales4.cmd b/code/lists/whales4.cmd deleted file mode 100755 index ff1d455..0000000 --- a/code/lists/whales4.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> whales = [5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, 7, 1, 3] ->>> whales[-1] -3 ->>> whales[-2] -1 ->>> whales[-14] -5 diff --git a/code/lists/whales5.cmd b/code/lists/whales5.cmd deleted file mode 100755 index 56a6d10..0000000 --- a/code/lists/whales5.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> whales = [5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, 7, 1, 3] ->>> third = whales[2] ->>> print 'Third day:', third -Third day: 7 diff --git a/code/lists/whales6.cmd b/code/lists/whales6.cmd deleted file mode 100755 index 62781ce..0000000 --- a/code/lists/whales6.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> whales = [] ->>> whales[0] -Traceback (most recent call last): - File "", line 1, in -IndexError: list index out of range ->>> whales[-1] -Traceback (most recent call last): - File "", line 1, in -IndexError: list index out of range diff --git a/code/loop/buggy_scan.py b/code/loop/buggy_scan.py deleted file mode 100755 index b184245..0000000 --- a/code/loop/buggy_scan.py +++ /dev/null @@ -1,9 +0,0 @@ -def double_preceding(values): - if values == []: - pass # do nothing to the empty list - else: - temp = values[0] - values[0] = 0 - for i in range(1, len(values)): - values[i] = 2 * temp - temp = values[i] diff --git a/code/loop/complex_cond.py b/code/loop/complex_cond.py deleted file mode 100755 index d91c0a1..0000000 --- a/code/loop/complex_cond.py +++ /dev/null @@ -1,10 +0,0 @@ -def f(a, b, c): - if a: - if b: - print 'hi' - elif c: - print 'bonjour' - else: - print 'hola' - else: - print 'Select a language.' diff --git a/code/loop/complex_cond_2.py b/code/loop/complex_cond_2.py deleted file mode 100755 index 5277e06..0000000 --- a/code/loop/complex_cond_2.py +++ /dev/null @@ -1,9 +0,0 @@ -def f(a, b, c): - if a and b: - print 'hi' - elif a and c: - print 'bonjour' - elif a: - print 'hola' - else: - print 'Select a language' diff --git a/code/loop/debug.cmd b/code/loop/debug.cmd deleted file mode 100755 index e4c7d3d..0000000 --- a/code/loop/debug.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> count_fragments('atc', 'gttacgtggatg') -0 ->>> count_fragments('gtg', 'gttacgtggatg') diff --git a/code/loop/debug.py b/code/loop/debug.py deleted file mode 100755 index 0dab353..0000000 --- a/code/loop/debug.py +++ /dev/null @@ -1,7 +0,0 @@ -def count_fragments(fragment, dna): - count = -1 - last_match = 0 - while last_match != -1: - count += 1 - last_match = dna.find(fragment, last_match) - return count diff --git a/code/loop/debug2.cmd b/code/loop/debug2.cmd deleted file mode 100755 index ddf3737..0000000 --- a/code/loop/debug2.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> count_fragments('gtg', 'gttacgtggatg') -1 ->>> count_fragments('gtt', 'gttacgtggatg') -0 diff --git a/code/loop/debug2.py b/code/loop/debug2.py deleted file mode 100755 index a9cd223..0000000 --- a/code/loop/debug2.py +++ /dev/null @@ -1,7 +0,0 @@ -def count_fragments(fragment, dna): - count = -1 - last_match = 0 - while last_match != -1: - count += 1 - last_match = dna.find(fragment, last_match + 1) - return count diff --git a/code/loop/different_lengths.cmd b/code/loop/different_lengths.cmd deleted file mode 100755 index 6005414..0000000 --- a/code/loop/different_lengths.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> info = [['Isaac Newton', 1643, 1727], - ['Charles Darwin', 1809, 1882], - ['Alan Turing', 1912, 1954, 'alan@bletchley.uk']] ->>> for item in info: -... print len(item) -... -3 -3 -4 diff --git a/code/loop/enumerate.cmd b/code/loop/enumerate.cmd deleted file mode 100755 index 23b8e43..0000000 --- a/code/loop/enumerate.cmd +++ /dev/null @@ -1,12 +0,0 @@ ->>> for x in enumerate('abc'): -... print x -... -(0, 'a') -(1, 'b') -(2, 'c') ->>> for x in enumerate([10, 20, 30]): -... print x -... -(0, 10) -(1, 20) -(2, 30) diff --git a/code/loop/enumerate_2.cmd b/code/loop/enumerate_2.cmd deleted file mode 100755 index 0dec469..0000000 --- a/code/loop/enumerate_2.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> values = [1, 2, 3] ->>> for pair in enumerate(values): -... i = pair[0] -... v = pair[1] -... values[i] = 2 * v -... ->>> values -[2, 4, 6] diff --git a/code/loop/enumerate_3.cmd b/code/loop/enumerate_3.cmd deleted file mode 100755 index e1d17aa..0000000 --- a/code/loop/enumerate_3.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> values = [1, 2, 3] ->>> for (i, v) in enumerate(values): -... values[i] = 2 * v -... ->>> values -[2, 4, 6] diff --git a/code/loop/fileinput_continue_data.cmd b/code/loop/fileinput_continue_data.cmd deleted file mode 100755 index a8826ad..0000000 --- a/code/loop/fileinput_continue_data.cmd +++ /dev/null @@ -1,11 +0,0 @@ -# Pluto is only 0.002 times the mass of Earth. -Pluto -Mercury -# Mars is half Earth's diameter, but only -# 0.11 times Earth's mass. -Mars -Venus -Earth -Uranus - - diff --git a/code/loop/filesearch_break.py b/code/loop/filesearch_break.py deleted file mode 100755 index 5ed3b9b..0000000 --- a/code/loop/filesearch_break.py +++ /dev/null @@ -1,8 +0,0 @@ -earth_line = 1 -file = open("data.txt", "r") -for line in file: - line = line.strip() - if line == "Earth": - break - earth_line = earth_line + 1 -print "Earth is at line %d" % earth_line diff --git a/code/loop/filesearch_continue.cmd b/code/loop/filesearch_continue.cmd deleted file mode 100755 index dd722ca..0000000 --- a/code/loop/filesearch_continue.cmd +++ /dev/null @@ -1,10 +0,0 @@ -entry_number = 1 -file = open("data.txt", "r") -for line in file : - line = line.strip() - if line.startswith("#"): - continue - if line == "Earth": - break - entry_number = entry_number + 1 -print "Earth is the %dth-lightest planet." % (entry_number) diff --git a/code/loop/filesearch_if.py b/code/loop/filesearch_if.py deleted file mode 100755 index cfc26ba..0000000 --- a/code/loop/filesearch_if.py +++ /dev/null @@ -1,9 +0,0 @@ -entry_number = 1 -file = open("data.txt", "r") -for line in file : - line = line.strip() - if not line.startswith("#"): - if line == "Earth": - break - entry_number = entry_number + 1 -print "Earth is the %dth-lightest planet." % (entry_number) diff --git a/code/loop/filesearch_nobreak.py b/code/loop/filesearch_nobreak.py deleted file mode 100755 index 29b8211..0000000 --- a/code/loop/filesearch_nobreak.py +++ /dev/null @@ -1,9 +0,0 @@ -current_line = 1 -earth_line = 0 -file = open("data.txt", "r") -for line in file: - line = line.strip() - if line == "Earth": - earth_line = current_line - current_line = current_line + 1 -print "Earth is at line %d" % earth_line diff --git a/code/loop/for_loop.cmd b/code/loop/for_loop.cmd deleted file mode 100755 index ef1fa63..0000000 --- a/code/loop/for_loop.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> for c in 'alpha': -... print c -... -a -l -p -h -a diff --git a/code/loop/for_nested.py b/code/loop/for_nested.py deleted file mode 100755 index 5afc6e6..0000000 --- a/code/loop/for_nested.py +++ /dev/null @@ -1,8 +0,0 @@ -import media -lake = media.load_picture('lake.png') -width, height = media.get_width(lake), media.get_height(lake) -for y in range(0, height, 2): # Skip odd-numbered lines - for x in range(0, width): - p = media.get_pixel(lake, x, y) - media.set_color(p, media.black) -media.show(lake) diff --git a/code/loop/for_rangebasic.cmd b/code/loop/for_rangebasic.cmd deleted file mode 100755 index 74c9095..0000000 --- a/code/loop/for_rangebasic.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> sum = 0 ->>> for i in range(1, 101): -... sum += i -... ->>> sum -5050 diff --git a/code/loop/for_rangestepping.cmd b/code/loop/for_rangestepping.cmd deleted file mode 100755 index cf81d9a..0000000 --- a/code/loop/for_rangestepping.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> range(2000, 2050, 4) -[2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048] diff --git a/code/loop/for_rangestepping2.cmd b/code/loop/for_rangestepping2.cmd deleted file mode 100755 index 91216c5..0000000 --- a/code/loop/for_rangestepping2.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> range(2050, 2000, -4) -[2050, 2046, 2042, 2038, 2034, 2030, 2026, 2022, 2018, 2014, 2010, 2006, 2002] diff --git a/code/loop/for_rangestepping_empty.cmd b/code/loop/for_rangestepping_empty.cmd deleted file mode 100755 index bf6ed36..0000000 --- a/code/loop/for_rangestepping_empty.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> range(2050, 2000, 4) -[] ->>> range(2000, 2050, -4) -[] diff --git a/code/loop/multi_assign.cmd b/code/loop/multi_assign.cmd deleted file mode 100755 index 73bc5fd..0000000 --- a/code/loop/multi_assign.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> x, y = 1, 2 ->>> x -1 ->>> y -2 diff --git a/code/loop/multi_assign_explode.cmd b/code/loop/multi_assign_explode.cmd deleted file mode 100755 index 032655c..0000000 --- a/code/loop/multi_assign_explode.cmd +++ /dev/null @@ -1,14 +0,0 @@ ->>> first, second, third = [1, 2, 3] ->>> first -1 ->>> second -2 ->>> third -3 ->>> first, second, third = 'abc' ->>> first -'a' ->>> second -'b' ->>> third -'c' diff --git a/code/loop/multiloop.py b/code/loop/multiloop.py deleted file mode 100755 index 909f6cb..0000000 --- a/code/loop/multiloop.py +++ /dev/null @@ -1,12 +0,0 @@ -import media -baseball = media.load_picture('baseball.png') -lake = media.load_picture('lake.png') -width, height = media.get_width(baseball), media.get_height(baseball) - -for y in range(0, height): - for x in range(0, width): - # Position the top-left of the baseball at (50, 25) - from_p = media.get_pixel(baseball, x, y) - to_p = media.get_pixel(lake, 50 + x, 25 + y) - media.set_color(to_p, media.get_color(from_p)) -media.show(lake) diff --git a/code/loop/nested_for.cmd b/code/loop/nested_for.cmd deleted file mode 100755 index 0aa44bc..0000000 --- a/code/loop/nested_for.cmd +++ /dev/null @@ -1,19 +0,0 @@ ->>> times = [["9:02", "10:17", "13:52", "18:23", "21:31"], -... ["8:45", "12:44", "14:52", "22:17"], -... ["8:55", "11:11", "12:34", "13:46", "15:52", "17:08", "21:15"], -... ["9:15", "11:44", "16:28"], -... ["10:01", "13:33", "16:45", "19:00"], -... ["9:34", "11:16", "15:52", "20:37"], -... ["9:01", "12:24", "18:51", "23:13"]] ->>> for day in times: -... for time in day: -... print time, -... print -... -9:02 10:17 13:52 18:23 21:31 -8:45 12:44 14:52 22:17 -8:55 11:11 12:34 13:46 15:52 17:08 21:15 -9:15 11:44 16:28 -10:01 13:33 16:45 19:00 -9:34 11:16 15:52 20:37 -9:01 12:24 18:51 23:13 diff --git a/code/loop/range_basic.cmd b/code/loop/range_basic.cmd deleted file mode 100755 index aeb4317..0000000 --- a/code/loop/range_basic.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> range(1, 5) -[1, 2, 3, 4] ->>> range(1, 10) -[1, 2, 3, 4, 5, 6, 7, 8, 9] ->>> range(5, 10) -[5, 6, 7, 8, 9] ->>> range(10) -[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ->>> diff --git a/code/loop/range_len.cmd b/code/loop/range_len.cmd deleted file mode 100755 index ad11de6..0000000 --- a/code/loop/range_len.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> values = ['a', 'b', 'c'] ->>> len(values) -3 ->>> range(3) -[0, 1, 2] ->>> range(len(values)) -[0, 1, 2] diff --git a/code/loop/range_len_2.cmd b/code/loop/range_len_2.cmd deleted file mode 100755 index 6654067..0000000 --- a/code/loop/range_len_2.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> values = ['a', 'b', 'c'] ->>> for i in range(len(values)): -... print i -... -0 -1 -2 diff --git a/code/loop/range_len_3.cmd b/code/loop/range_len_3.cmd deleted file mode 100755 index 71a8506..0000000 --- a/code/loop/range_len_3.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> values = ['a', 'b', 'c'] ->>> for i in range(len(values)): -... print i, values[i] -... -0 a -1 b -2 c diff --git a/code/loop/range_len_4.cmd b/code/loop/range_len_4.cmd deleted file mode 100755 index b9b2f09..0000000 --- a/code/loop/range_len_4.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> values = ['a', 'b', 'c'] ->>> for i in range(len(values)): -... values[i] = 'X' -... ->>> values -['X', 'X', 'X'] diff --git a/code/loop/range_len_5.cmd b/code/loop/range_len_5.cmd deleted file mode 100755 index fb4aca0..0000000 --- a/code/loop/range_len_5.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> values = [1, 2, 3] ->>> for i in range(len(values)): -... values[i] = 2 * values[i] -... ->>> values -[2, 4, 6] diff --git a/code/loop/range_len_6.cmd b/code/loop/range_len_6.cmd deleted file mode 100755 index 85dccdb..0000000 --- a/code/loop/range_len_6.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> values = [1, 2, 3] ->>> for i in range(len(values)): -... values[i] *= 2 -... ->>> values -[2, 4, 6] diff --git a/code/loop/range_single.cmd b/code/loop/range_single.cmd deleted file mode 100755 index 2061ecd..0000000 --- a/code/loop/range_single.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> range(10) -[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ->>> range(1) -[0] ->>> range(0) -[] diff --git a/code/loop/shrinking_list.py b/code/loop/shrinking_list.py deleted file mode 100755 index c795809..0000000 --- a/code/loop/shrinking_list.py +++ /dev/null @@ -1,6 +0,0 @@ -def remove_neg(num_list): - '''Remove the negative numbers from the list num_list.''' - for item in num_list: - if item < 0: - num_list.remove(item) - diff --git a/code/loop/simple_while.cmd b/code/loop/simple_while.cmd deleted file mode 100755 index 4f13425..0000000 --- a/code/loop/simple_while.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> rabbits = 3 ->>> while rabbits > 0: -... print rabbits -... rabbits -= 1 -... -3 -2 -1 diff --git a/code/loop/userinputloop.py b/code/loop/userinputloop.py deleted file mode 100755 index 8bd54aa..0000000 --- a/code/loop/userinputloop.py +++ /dev/null @@ -1,13 +0,0 @@ -text = "" -while text != "quit": - text = raw_input("Please enter a chemical formula (or 'quit' to exit): ") - if text == "quit": - print "...exiting program" - elif text == "H2O": - print "Water" - elif text == "NH3": - print "Ammonia" - elif text == "CH3": - print "Methane" - else: - print "Unknown compound" diff --git a/code/loop/userinputloop_infinite.py b/code/loop/userinputloop_infinite.py deleted file mode 100755 index b63c788..0000000 --- a/code/loop/userinputloop_infinite.py +++ /dev/null @@ -1,10 +0,0 @@ -while True: - formula = raw_input("Please enter a chemical formula: ") - if formula == "H2O": - print "Water" - elif formula == "NH3": - print "Ammonia" - elif formula == "CH3": - print "Methane" - else: - print "Unknown compound" diff --git a/code/loop/userinputloop_infinite_output.cmd b/code/loop/userinputloop_infinite_output.cmd deleted file mode 100755 index 5bada0c..0000000 --- a/code/loop/userinputloop_infinite_output.cmd +++ /dev/null @@ -1,7 +0,0 @@ -Please enter a chemical formula: NH3 -Ammonia -Please enter a chemical formula: H2O -Water -Please enter a chemical formula: NaCl -Unknown compound -... diff --git a/code/loop/userinputloop_output.cmd b/code/loop/userinputloop_output.cmd deleted file mode 100755 index aa3e726..0000000 --- a/code/loop/userinputloop_output.cmd +++ /dev/null @@ -1,6 +0,0 @@ -Please enter a chemical formula (or 'quit' to exit): CH3 -Methane -Please enter a chemical formula (or 'quit' to exit): H2O -Water -Please enter a chemical formula (or 'quit' to exit): quit -...exiting program diff --git a/code/loop/while_infinite.py b/code/loop/while_infinite.py deleted file mode 100755 index 19e857b..0000000 --- a/code/loop/while_infinite.py +++ /dev/null @@ -1,9 +0,0 @@ -# Use multi-valued assignment to set up controls. -time, population, growth_rate = 0, 1000, 0.21 - -# Don't stop until we're exactly double original size. -while population != 2000: - population = population + growth_rate * population - print population - time = time + 1 -print "It took %d minutes for the bacteria to double." % time diff --git a/code/loop/while_infinite_output.cmd b/code/loop/while_infinite_output.cmd deleted file mode 100755 index 7f51ffb..0000000 --- a/code/loop/while_infinite_output.cmd +++ /dev/null @@ -1,10 +0,0 @@ -1210.0 -1464.1 -1771.561 -2143.58881 -2593.7424601 -...3,680 lines or so later... -inf -inf -inf -...and so on forever... \ No newline at end of file diff --git a/code/loop/whileloop.py b/code/loop/whileloop.py deleted file mode 100755 index 70fa377..0000000 --- a/code/loop/whileloop.py +++ /dev/null @@ -1,9 +0,0 @@ -time = 0 -population = 1000 # 1000 bacteria to start with -growth_rate = 0.21 # 21% growth per minute -while population < 2000: - population = population + growth_rate * population - print population - time = time + 1 -print "It took %d minutes for the bacteria to double." % time -print "...and the final population was %6.2f bacteria." % population diff --git a/code/loop/whileloop_output.cmd b/code/loop/whileloop_output.cmd deleted file mode 100755 index 5a6278e..0000000 --- a/code/loop/whileloop_output.cmd +++ /dev/null @@ -1,6 +0,0 @@ -1210.0 -1464.1 -1771.561 -2143.58881 -It took 4 minutes for the bacteria to double. -...and the final population was 2143.59 bacteria. diff --git a/code/modules/assert.py b/code/modules/assert.py deleted file mode 100755 index 6dc31f8..0000000 --- a/code/modules/assert.py +++ /dev/null @@ -1,17 +0,0 @@ -import nose -from temp_with_doc import to_celsius - -def test_freezing(): - '''Test freezing point.''' - assert to_celsius(32) == 0 - -def test_boiling(): - '''Test boiling point.''' - assert to_celsius(212) == 100 - -def test_roundoff(): - '''Test that roundoff works.''' - assert to_celsius(100) == 38 # NOT 37.777... - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/modules/assert2.py b/code/modules/assert2.py deleted file mode 100755 index 225630b..0000000 --- a/code/modules/assert2.py +++ /dev/null @@ -1,7 +0,0 @@ -import nose -from temp_with_doc import to_celsius -def test_to_celsius(): - '''Test function for to_celsius''' - assert to_celsius(100) == 37.8 -if __name__ == '__main__': - nose.runmodule() diff --git a/code/modules/assert3.py b/code/modules/assert3.py deleted file mode 100755 index c89a025..0000000 --- a/code/modules/assert3.py +++ /dev/null @@ -1,7 +0,0 @@ -import nose -from temp_with_doc import to_celsius -def test_to_celsius(): - '''Test function for to_celsius''' - assert to_celsius(100) == 37.8, 'Returning an unrounded result' -if __name__ == '__main__': - nose.runmodule() diff --git a/code/modules/convert.py b/code/modules/convert.py deleted file mode 100755 index e186b7d..0000000 --- a/code/modules/convert.py +++ /dev/null @@ -1,2 +0,0 @@ -def to_celsius(t): - return (t - 32.0) * 5.0 / 9.0 diff --git a/code/modules/dir1.cmd b/code/modules/dir1.cmd deleted file mode 100755 index bd777fc..0000000 --- a/code/modules/dir1.cmd +++ /dev/null @@ -1,28 +0,0 @@ ->>> dir(__builtins__) -['ArithmeticError', 'AssertionError', 'AttributeError', -'BaseException', 'DeprecationWarning', 'EOFError', 'Ellipsis', -'EnvironmentError', 'Exception', 'False', 'FloatingPointError', -'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', -'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', -'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', -'None', 'NotImplemented', 'NotImplementedError', 'OSError', -'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', -'RuntimeError', 'RuntimeWarning', 'StandardError', -'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', -'SystemExit', 'TabError', 'True', 'TypeError', -'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', -'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', -'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '_', -'__debug__', '__doc__', '__import__', '__name__', 'abs', 'all', -'any', 'apply', 'basestring', 'bool', 'buffer', 'callable', -'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', -'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', -'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', -'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', -'help', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', -'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', -'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', -'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', -'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', -'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', -'unicode', 'vars', 'xrange', 'zip'] \ No newline at end of file diff --git a/code/modules/distance.py b/code/modules/distance.py deleted file mode 100755 index 9185316..0000000 --- a/code/modules/distance.py +++ /dev/null @@ -1,6 +0,0 @@ -import math - -def distance(x0, y0, x1, y1): - '''Calculate the distance between (x0, y0) and (x1, y1).''' - - return math.sqrt((x1 - x0) ** 2 + (y1 - y0) ** 2) diff --git a/code/modules/echo.cmd b/code/modules/echo.cmd deleted file mode 100755 index 10ff156..0000000 --- a/code/modules/echo.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> import echo -echo: __name__ is echo diff --git a/code/modules/echo.out b/code/modules/echo.out deleted file mode 100755 index d363a84..0000000 --- a/code/modules/echo.out +++ /dev/null @@ -1 +0,0 @@ -echo: __name__ is __main__ diff --git a/code/modules/echo.py b/code/modules/echo.py deleted file mode 100755 index f1d6fcd..0000000 --- a/code/modules/echo.py +++ /dev/null @@ -1 +0,0 @@ -print "echo: __name__ is", __name__ diff --git a/code/modules/endswith.cmd b/code/modules/endswith.cmd deleted file mode 100755 index 6c336f1..0000000 --- a/code/modules/endswith.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 'species'.endswith('a') -False ->>> 'species'.endswith('s') -True diff --git a/code/modules/experiment.py b/code/modules/experiment.py deleted file mode 100755 index fb7c931..0000000 --- a/code/modules/experiment.py +++ /dev/null @@ -1 +0,0 @@ -print "The panda's scientific name is 'Ailuropoda melanoleuca'" diff --git a/code/modules/fail.out b/code/modules/fail.out deleted file mode 100755 index d12b2a5..0000000 --- a/code/modules/fail.out +++ /dev/null @@ -1,14 +0,0 @@ -F -====================================================================== -FAIL: Test function for to_celsius ----------------------------------------------------------------------- -Traceback (most recent call last): - File "/python25/lib/site-packages/nose/case.py", line 202, in runTest - self.test(*self.arg) - File "assert2.py", line 6, in test_to_celsius - assert to_celsius(100) == 37.8 -AssertionError ----------------------------------------------------------------------- -Ran 1 test in 0.000s - -FAILED (failures=1) diff --git a/code/modules/fail_comment.out b/code/modules/fail_comment.out deleted file mode 100755 index 5f9312c..0000000 --- a/code/modules/fail_comment.out +++ /dev/null @@ -1,15 +0,0 @@ -F -====================================================================== -FAIL: Test function for to_celsius ----------------------------------------------------------------------- -Traceback (most recent call last): - File "c:\Python25\Lib\site-packages\nose\case.py", line 202, in runTest - self.test(*self.arg) - File "assert3.py", line 6, in test_to_celsius - assert to_celsius(100) == 37.8, 'Returning an unrounded result' -AssertionError: Returning an unrounded result - ----------------------------------------------------------------------- -Ran 1 test in 0.000s - -FAILED (failures=1) diff --git a/code/modules/freezing.py b/code/modules/freezing.py deleted file mode 100755 index 20eb493..0000000 --- a/code/modules/freezing.py +++ /dev/null @@ -1,2 +0,0 @@ -def above_freezing(t): - return t > 0 diff --git a/code/modules/from.cmd b/code/modules/from.cmd deleted file mode 100755 index f4196b0..0000000 --- a/code/modules/from.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> from math import sqrt, pi ->>> sqrt(9) -3.0 ->>> radius = 5 ->>> print 'circumference is %6f' % (2 * pi * radius) -circumference is 31.415927 diff --git a/code/modules/from2.cmd b/code/modules/from2.cmd deleted file mode 100755 index 60565a6..0000000 --- a/code/modules/from2.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> from math import * ->>> '%6f' % sqrt(8) -'2.828427' diff --git a/code/modules/help_math.cmd b/code/modules/help_math.cmd deleted file mode 100755 index 3cc2dfd..0000000 --- a/code/modules/help_math.cmd +++ /dev/null @@ -1,25 +0,0 @@ ->>> help(math) -Help on built-in module math: - - -NAME - math - -FILE - (built-in) - -DESCRIPTION - This module is always available. It provides access to the - mathematical functions defined by the C standard. - -FUNCTIONS - acos(...) - acos(x) - - Return the arc cosine (measured in radians) of x. - - asin(...) - asin(x) - - Return the arc sine (measured in radians) of x. -... diff --git a/code/modules/help_temp.cmd b/code/modules/help_temp.cmd deleted file mode 100755 index 28b5734..0000000 --- a/code/modules/help_temp.cmd +++ /dev/null @@ -1,14 +0,0 @@ ->>> import temp_round ->>> help(temp_round) -Help on module temp_round: - -NAME - temp_round - -FILE - /home/pybook/modules/temp_round.py - -FUNCTIONS - above_freezing(t) - - to_celsius(t) diff --git a/code/modules/help_temp_with_doc.cmd b/code/modules/help_temp_with_doc.cmd deleted file mode 100755 index b4a8ff4..0000000 --- a/code/modules/help_temp_with_doc.cmd +++ /dev/null @@ -1,16 +0,0 @@ ->>> import temp_with_doc ->>> help(temp_with_doc) -Help on module temp_with_doc: - -NAME - temp_with_doc - Functions for working with temperatures. - -FILE - /home/pybook/modules/temp_with_doc.py - -FUNCTIONS - above_freezing(t) - True if temperature in Celsius is above freezing, False otherwise. - - to_celsius(t) - Convert Fahrenheit to Celsius. diff --git a/code/modules/import.cmd b/code/modules/import.cmd deleted file mode 100755 index 0e92dcc..0000000 --- a/code/modules/import.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> import math - diff --git a/code/modules/import_ambiguity.cmd b/code/modules/import_ambiguity.cmd deleted file mode 100755 index 819b8e3..0000000 --- a/code/modules/import_ambiguity.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> import math ->>> import building ->>> floor(22.7) diff --git a/code/modules/import_echo.out b/code/modules/import_echo.out deleted file mode 100755 index fe91ea1..0000000 --- a/code/modules/import_echo.out +++ /dev/null @@ -1,2 +0,0 @@ -echo: __name__ is echo -After import, __name__ is __main__ and echo.__name__ is echo diff --git a/code/modules/import_echo.py b/code/modules/import_echo.py deleted file mode 100755 index 4b06faa..0000000 --- a/code/modules/import_echo.py +++ /dev/null @@ -1,2 +0,0 @@ -import echo -print "After import, __name__ is", __name__, "and echo.__name__ is", echo.__name__ diff --git a/code/modules/import_experiment.cmd b/code/modules/import_experiment.cmd deleted file mode 100755 index a24708b..0000000 --- a/code/modules/import_experiment.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> import experiment -The panda's scientific name is 'Ailuropoda melanoleuca' diff --git a/code/modules/import_temp.cmd b/code/modules/import_temp.cmd deleted file mode 100755 index c672c31..0000000 --- a/code/modules/import_temp.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> import temperature ->>> temperature.above_freezing(temperature.to_celsius(33.3)) -True diff --git a/code/modules/import_twice.cmd b/code/modules/import_twice.cmd deleted file mode 100755 index 1777d94..0000000 --- a/code/modules/import_twice.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> import experiment -The panda's scientific name is 'Ailuropoda melanoleuca' ->>> import experiment ->>> diff --git a/code/modules/int_help.cmd b/code/modules/int_help.cmd deleted file mode 100755 index 8ffa073..0000000 --- a/code/modules/int_help.cmd +++ /dev/null @@ -1,21 +0,0 @@ ->>> help(0) -Help on int object: - -class int(object) - | int(x[, base]) -> integer - | - | Convert a string or number to an integer, if possible. A floating point - | argument will be truncated towards zero (this does not include a string - | representation of a floating point number!) When converting a string, use - | the optional base. It is an error to supply a base when converting a - | non-string. If the argument is outside the integer range a long object - | will be returned instead. - | - | Methods defined here: - | - | __abs__(...) - | x.__abs__() <==> abs(x) - | - | __add__(...) - | x.__add__(y) <==> x+y -... diff --git a/code/modules/main_help.py b/code/modules/main_help.py deleted file mode 100755 index 20676fb..0000000 --- a/code/modules/main_help.py +++ /dev/null @@ -1,12 +0,0 @@ -''' -This module guesses whether something is a dinosaur or not. -''' - -def is_dinosaur(name): - ''' - Return True if the named creature is recognized as a dinosaur, - and False otherwise. - ''' - return name in ['Tyrannosaurus', 'Triceratops'] -if __name__ == '__main__': - help(__name__) diff --git a/code/modules/open_pic.cmd b/code/modules/open_pic.cmd deleted file mode 100755 index 84b899e..0000000 --- a/code/modules/open_pic.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> import media ->>> f = media.choose_file() ->>> pic = media.load_picture(f) ->>> media.show(pic) diff --git a/code/modules/outcome.out b/code/modules/outcome.out deleted file mode 100755 index b6a98dd..0000000 --- a/code/modules/outcome.out +++ /dev/null @@ -1,5 +0,0 @@ -... ----------------------------------------------------------------------- -Ran 3 tests in 0.002s - -OK diff --git a/code/modules/pi.cmd b/code/modules/pi.cmd deleted file mode 100755 index 16a3fa3..0000000 --- a/code/modules/pi.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> math.pi -3.1415926535897931 ->>> radius = 5 ->>> print 'area is %6f' % (math.pi * radius ** 2) -area is 78.539816 diff --git a/code/modules/pi_change.cmd b/code/modules/pi_change.cmd deleted file mode 100755 index 5f07a8f..0000000 --- a/code/modules/pi_change.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> import math ->>> math.pi = 3 # would turn circles into hexagons ->>> radius = 5 ->>> print 'circumference is', 2 * math.pi * radius -circumference is 30 diff --git a/code/modules/pic_crop.cmd b/code/modules/pic_crop.cmd deleted file mode 100755 index 9a23c40..0000000 --- a/code/modules/pic_crop.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> media.crop_picture(pic, 150, 50, 450, 300) ->>> media.show(pic) ->>> media.save_as(pic, 'pic207cropped.jpg') diff --git a/code/modules/pic_props.cmd b/code/modules/pic_props.cmd deleted file mode 100755 index 6eb9df1..0000000 --- a/code/modules/pic_props.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> pic.get_width() -500 ->>> pic.get_height() -375 ->>> pic.title -'modules/pic207.jpg' diff --git a/code/modules/pic_text.cmd b/code/modules/pic_text.cmd deleted file mode 100755 index e792703..0000000 --- a/code/modules/pic_text.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> media.add_text(pic, 115, 40, 'Madeleine', media.magenta) ->>> media.show(pic) diff --git a/code/modules/show_madeleine.py b/code/modules/show_madeleine.py deleted file mode 100755 index 04de626..0000000 --- a/code/modules/show_madeleine.py +++ /dev/null @@ -1,8 +0,0 @@ -import media - -pic1 = media.load_picture('pic207.jpg') -media.show(pic1) -pic2 = media.load_picture('pic207cropped.jpg') -media.show(pic2) -pic3 = media.load_picture('pic207named.jpg') -media.show(pic3) \ No newline at end of file diff --git a/code/modules/sqrt.cmd b/code/modules/sqrt.cmd deleted file mode 100755 index 9d3234d..0000000 --- a/code/modules/sqrt.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> sqrt(9) -Traceback (most recent call last): - File "", line 1, in -NameError: name 'sqrt' is not defined diff --git a/code/modules/sqrt2.cmd b/code/modules/sqrt2.cmd deleted file mode 100755 index 9e427f8..0000000 --- a/code/modules/sqrt2.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> math.sqrt(9) -3.0 diff --git a/code/modules/startswith.cmd b/code/modules/startswith.cmd deleted file mode 100755 index 0ce2cfd..0000000 --- a/code/modules/startswith.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 'species'.startswith('a') -False ->>> 'species'.startswith('s') -True diff --git a/code/modules/structure.out b/code/modules/structure.out deleted file mode 100755 index c81d30b..0000000 --- a/code/modules/structure.out +++ /dev/null @@ -1,5 +0,0 @@ -.. ----------------------------------------------------------------------- -Ran 2 tests in 0.000s - -OK diff --git a/code/modules/structure.py b/code/modules/structure.py deleted file mode 100755 index 5445b16..0000000 --- a/code/modules/structure.py +++ /dev/null @@ -1,13 +0,0 @@ -import nose -import temperature - -def test_to_celsius(): - '''Test function for to_celsius''' - pass # we'll fill this in later - -def test_above_freezing(): - '''Test function for above_freezing.''' - pass # we'll fill this in too - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/modules/sunset.py b/code/modules/sunset.py deleted file mode 100755 index 74ddca6..0000000 --- a/code/modules/sunset.py +++ /dev/null @@ -1,11 +0,0 @@ -import media - -pic = media.load_picture('pic207.jpg') -media.show(pic) -for p in media.get_pixels(pic): - new_blue = int(0.7 * media.get_blue(p)) - new_green = int(0.7 * media.get_green(p)) - media.set_blue(p, new_blue) - media.set_green(p, new_green) - -media.show(pic) diff --git a/code/modules/swap.cmd b/code/modules/swap.cmd deleted file mode 100755 index 1d26167..0000000 --- a/code/modules/swap.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 'Computer Science'.swapcase() -'cOMPUTER sCIENCE' diff --git a/code/modules/swap_endswith.cmd b/code/modules/swap_endswith.cmd deleted file mode 100755 index b44f695..0000000 --- a/code/modules/swap_endswith.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 'Computer Science'.swapcase().endswith('ENCE') -True diff --git a/code/modules/temp_round.py b/code/modules/temp_round.py deleted file mode 100755 index 67cbf98..0000000 --- a/code/modules/temp_round.py +++ /dev/null @@ -1,5 +0,0 @@ -def to_celsius(t): - return round((t - 32.0) * 5.0 / 9.0) - -def above_freezing(t): - return t > 0 diff --git a/code/modules/temp_with_doc.py b/code/modules/temp_with_doc.py deleted file mode 100755 index 515af03..0000000 --- a/code/modules/temp_with_doc.py +++ /dev/null @@ -1,9 +0,0 @@ -'''Functions for working with temperatures.''' - -def to_celsius(t): - '''Convert Fahrenheit to Celsius.''' - return round((t - 32.0) * 5.0 / 9.0) - -def above_freezing(t): - '''True if temperature in Celsius is above freezing, False otherwise.''' - return t > 0 diff --git a/code/modules/temperature.py b/code/modules/temperature.py deleted file mode 100755 index 2903eb0..0000000 --- a/code/modules/temperature.py +++ /dev/null @@ -1,5 +0,0 @@ -def to_celsius(t): - return (t - 32.0) * 5.0 / 9.0 - -def above_freezing(t): - return t > 0 diff --git a/code/modules/test_distance.py b/code/modules/test_distance.py deleted file mode 100755 index e0db325..0000000 --- a/code/modules/test_distance.py +++ /dev/null @@ -1,17 +0,0 @@ -import nose -from distance import distance - - -def close(left, right): - '''Test if two floating-point values are close enough.''' - - return abs(left - right) < 1.0e-6 - -def test_distance(): - '''Test whether the distance function works correctly.''' - - assert close(distance(1.0, 0.0, 1.0, 0.0), 0.0), 'Identical points fail.' - assert close(distance(0.0, 0.0, 1.0, 0.0), 1.0), 'Unit distance fails.' - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/modules/test_freezing.out b/code/modules/test_freezing.out deleted file mode 100755 index 1eed870..0000000 --- a/code/modules/test_freezing.out +++ /dev/null @@ -1,5 +0,0 @@ -. ----------------------------------------------------------------------- -Ran 1 test in 0.000s - -OK diff --git a/code/modules/test_freezing.py b/code/modules/test_freezing.py deleted file mode 100755 index 7c12ca2..0000000 --- a/code/modules/test_freezing.py +++ /dev/null @@ -1,11 +0,0 @@ -import nose -from temp_with_doc import above_freezing - -def test_above_freezing(): - '''Test function for above_freezing.''' - assert above_freezing(89.4), 'A temperature above freezing.' - assert not above_freezing(-42), 'A temperature below freezing.' - assert not above_freezing(0), 'A temperature at freezing.' - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/modules/test_main.py b/code/modules/test_main.py deleted file mode 100755 index e2f7faf..0000000 --- a/code/modules/test_main.py +++ /dev/null @@ -1,4 +0,0 @@ -if __name__ == "__main__": - print "I am the main program" -else: - print "Someone is importing me" diff --git a/code/modules/test_temperature.out b/code/modules/test_temperature.out deleted file mode 100755 index c81d30b..0000000 --- a/code/modules/test_temperature.out +++ /dev/null @@ -1,5 +0,0 @@ -.. ----------------------------------------------------------------------- -Ran 2 tests in 0.000s - -OK diff --git a/code/modules/test_temperature.py b/code/modules/test_temperature.py deleted file mode 100755 index 5445b16..0000000 --- a/code/modules/test_temperature.py +++ /dev/null @@ -1,13 +0,0 @@ -import nose -import temperature - -def test_to_celsius(): - '''Test function for to_celsius''' - pass # we'll fill this in later - -def test_above_freezing(): - '''Test function for above_freezing.''' - pass # we'll fill this in too - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/oop/arthropod.py b/code/oop/arthropod.py deleted file mode 100755 index 603722b..0000000 --- a/code/oop/arthropod.py +++ /dev/null @@ -1,23 +0,0 @@ -class Arthropod(Organism): - '''An arthropod that has a fixed number of legs.''' - - def __init__(self, name, x, y, legs): - '''An arthropod with the given number of legs that exists at location - (x, y) in the tide pool.''' - - Organism.__init__(self, name, x, y) - self.legs = legs - def __str__(self): - '''Return a string representation of this Arthropod.''' - - return '(%s, %s, [%s, %s])' % (self.name, self.legs, self.x, self.y) - - def is_decapod(self): - '''Return True if this Arthropod is a decapod.''' - - return self.legs == 10 - - def leg_count(self): - '''Return the number of legs this Arthropod possesses.''' - - return self.legs diff --git a/code/oop/arthropod_basic.py b/code/oop/arthropod_basic.py deleted file mode 100755 index 985e6f2..0000000 --- a/code/oop/arthropod_basic.py +++ /dev/null @@ -1,3 +0,0 @@ ->>> blue_crab = Arthropod('Callinectes sapidus', 0, 0) ->>> print blue_crab -(Callinectes sapidus, 0, 0) diff --git a/code/oop/arthropod_header.py b/code/oop/arthropod_header.py deleted file mode 100755 index 3c95337..0000000 --- a/code/oop/arthropod_header.py +++ /dev/null @@ -1,2 +0,0 @@ -class Arthropod(Organism): - pass diff --git a/code/oop/arthropod_init.py b/code/oop/arthropod_init.py deleted file mode 100755 index 7575339..0000000 --- a/code/oop/arthropod_init.py +++ /dev/null @@ -1,9 +0,0 @@ -class Arthropod(Organism): - '''An arthropod that has a fixed number of legs.''' - - def __init__(self, name, x, y, legs): - '''An arthropod with the given number of legs that exists at location - (x, y) in the tide pool.''' - - Organism.__init__(self, name, x, y) - self.legs = legs diff --git a/code/oop/arthropod_init_result.py b/code/oop/arthropod_init_result.py deleted file mode 100755 index 2071679..0000000 --- a/code/oop/arthropod_init_result.py +++ /dev/null @@ -1,5 +0,0 @@ ->>> lobster = Arthropod('Homarus gammarus', 0, 0) -Traceback (most recent call last): - File "", line 1, in -TypeError: __init__() takes exactly 5 arguments (4 given) ->>> lobster = Arthropod('Homarus gammarus', 0, 0, 10) diff --git a/code/oop/arthropod_str.py b/code/oop/arthropod_str.py deleted file mode 100755 index 41534d7..0000000 --- a/code/oop/arthropod_str.py +++ /dev/null @@ -1,3 +0,0 @@ ->>> lobster = Arthropod('Homarus gammarus', 0, 0, 10) ->>> print lobster -(Homarus gammarus, 0, 0) diff --git a/code/oop/arthropod_str_override.py b/code/oop/arthropod_str_override.py deleted file mode 100755 index f7fd664..0000000 --- a/code/oop/arthropod_str_override.py +++ /dev/null @@ -1,14 +0,0 @@ -class Arthropod(Organism): - '''An arthropod that has a fixed number of legs.''' - - def __init__(self, name, x, y, legs): - '''An arthropod with the given number of legs that exists at location - (x, y) in the tide pool.''' - - Organism.__init__(self, name, x, y) - self.legs = legs - - def __str__(self): - '''Return a string representation of this Arthropod.''' - - return '(%s, %s, [%s, %s])' % (self.name, self.legs, self.x, self.y) diff --git a/code/oop/atom.py b/code/oop/atom.py deleted file mode 100755 index 82c80b3..0000000 --- a/code/oop/atom.py +++ /dev/null @@ -1,49 +0,0 @@ -#START:init -class Atom(object): - '''An atom with a number, symbol, and coordinates.''' - - def __init__(self, num, sym, x, y, z): - '''Create an Atom with number num, string symbol sym, and float - coordinates (x, y, z).''' - self.number = num - self.center = (x, y, z) - self.symbol = sym -#END:init - -#START:translate - def translate(self, x, y, z): - '''Move this Atom by adding (x, y, z) to its coordinates.''' - - self.center = (self.center[0] + x, - self.center[1] + y, - self.center[2] + z) -#END:translate - -#START:str - def __str__(self): - '''Return a string representation of this Atom in this format: - - (SYMBOL, X, Y, Z) - ''' - - return '(%s, %s, %s, %s)' % \ - (self.symbol, self.center[0], self.center[1], self.center[2]) - - def __repr__(self): - '''Return a string representation of this Atom in this format: - - Atom("SYMBOL", X, Y, Z) - ''' - - return 'Atom(%s, "%s", %s, %s, %s)' % \ - (self.number, self.symbol, \ - self.center[0], self.center[1], self.center[2]) -#END:str - -if __name__ == '__main__': -#START:create_nitrogen - nitrogen = Atom(1, "N", 0.257, -0.363, 0.0) -#END:create_nitrogen -#START:translate_nitrogen - nitrogen.translate(0, 0, 0.2) -#END:translate_nitrogen diff --git a/code/oop/broken_color_self.py b/code/oop/broken_color_self.py deleted file mode 100755 index 3d78b6d..0000000 --- a/code/oop/broken_color_self.py +++ /dev/null @@ -1,8 +0,0 @@ -class Color(object): - '''An RGB color, with red, green and blue components.''' - def lightness(self): - '''Return the lightness of this color.''' - # Fails: no such variables 'red', 'green', and 'blue' - strongest = max(red, green, blue) - weakest = min(red, green, blue) - return 0.5 * (strongest + weakest) / 255 diff --git a/code/oop/color.py b/code/oop/color.py deleted file mode 100755 index 7e5fa58..0000000 --- a/code/oop/color.py +++ /dev/null @@ -1,10 +0,0 @@ -class Color(object): - '''An RGB color, with red, green and blue components.''' - - def __init__(self, r, g, b): - '''A new color with red value r, green value g, and blue value b. All - components are integers in the range 0-255.''' - - self.red = r - self.green = g - self.blue = b diff --git a/code/oop/color_add_bad.py b/code/oop/color_add_bad.py deleted file mode 100755 index d005b24..0000000 --- a/code/oop/color_add_bad.py +++ /dev/null @@ -1,10 +0,0 @@ -class Color(object): - ...other definitions as before... - - def __add__(self, other_color): - '''This is a bad way to define this method.''' - - self.red += other_color.red - self.green += other_color.green - self.blue += other_color.blue - return self diff --git a/code/oop/color_add_values.cmd b/code/oop/color_add_values.cmd deleted file mode 100755 index bbbc01a..0000000 --- a/code/oop/color_add_values.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> black.red = 0 ->>> black.green = 0 ->>> black.blue = 0 \ No newline at end of file diff --git a/code/oop/color_dict.cmd b/code/oop/color_dict.cmd deleted file mode 100755 index bab545e..0000000 --- a/code/oop/color_dict.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> black.__dict__ -{'blue': 0, 'green': 0, 'red': 0} \ No newline at end of file diff --git a/code/oop/color_dir.cmd b/code/oop/color_dir.cmd deleted file mode 100755 index ae7ec3c..0000000 --- a/code/oop/color_dir.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> black = Color(0, 0, 0) ->>> dir(black) -['__add__', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', - '__getattribute__', '__hash__', '__init__', '__module__', '__new__', - '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', - '__sub__', '__weakref__', 'blue', 'distance', 'green', 'red'] \ No newline at end of file diff --git a/code/oop/color_full.py b/code/oop/color_full.py deleted file mode 100755 index 8993126..0000000 --- a/code/oop/color_full.py +++ /dev/null @@ -1,41 +0,0 @@ -class Color(object): - '''An RGB color, with red, green and blue components.''' - - def __init__(self, r, g, b): - '''A new color with red value r, green value g, and blue value b. - All components are integers in the range 0-255.''' - - self.red = r - self.green = g - self.blue = b - - def __str__(self): - '''Return a string representation of this Color in the form - Color(red, green, blue).''' - - return 'Color(%s, %s, %s)' % (self.red, self.green, self.blue) - - def __add__(self, other_color): - '''Return a new Color made from adding the red, green, and blue - components of this Color to Color other_color's components. If the - sum is greater than 255, then the color is set to 255.''' - - return Color(min(self.red + other_color.red, 255), - min(self.green + other_color.green, 255), - min(self.blue + other_color.blue, 255)) - - def __sub__(self, other_color): - '''Return a new Color made from subtracting the red, green, and blue - components of this Color from Color other_color's components. If - the difference is less than 0, then the color is set to 0.''' - - return Color(max(self.red - other_color.red, 0), - max(self.green - other_color.green, 0), - max(self.blue - other_color.blue, 0)) - - def __eq__(self, other_color): - '''Return True if this Color's components are equal to Color - other_color's components.''' - - return self.red == other_color.red and self.green == \ - other_color.green and self.blue == other_color.blue diff --git a/code/oop/color_full_use.cmd b/code/oop/color_full_use.cmd deleted file mode 100755 index 527a373..0000000 --- a/code/oop/color_full_use.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> purple = Color(128, 0, 128) ->>> white = Color(255, 255, 255) ->>> dark_grey = Color(50, 50, 50) ->>> print purple + dark_grey -Color(178, 50, 178) ->>> print white - dark_grey -Color(205, 205, 205) ->>> print white == Color(255, 255, 255) -True \ No newline at end of file diff --git a/code/oop/color_help.cmd b/code/oop/color_help.cmd deleted file mode 100755 index c3a3c22..0000000 --- a/code/oop/color_help.cmd +++ /dev/null @@ -1,40 +0,0 @@ ->>> help(Color) -Help on class Color in module color_full_distance: - -class Color(__builtin__.object) - | An RGB color, with red, green and blue components. - | - | Methods defined here: - | - | __add__(self, other_color) - | Return a new Color made from adding the red, green, and blue - | components of this Color to Color other_color's components. - | If the sum is greater than 255, then the color is set to 255. - | - | __eq__(self, other_color) - | Return True if this Color's components are equal to Color - | other_color's components. - | - | __init__(self, r, g, b) - | A new color with red value r, green value g, and blue value b. All - | components are integers in the range 0-255. - | - | __str__(self) - | Return a string representation of this Color in the form - | Color(red, green, blue). - | - | __sub__(self, other_color) - | Return a new Color made from subtracting the red, green, and blue - | components of this Color from Color other_color's components. - | If the difference is less than 0, then the color is set to 0. - | - | lightness(self) - | Return the lightness of this color. - | ---------------------------------------------------------------------- - | Data descriptors defined here: - | - | __dict__ - | dictionary for instance variables (if defined) - | - | __weakref__ - | list of weak references to the object (if defined) \ No newline at end of file diff --git a/code/oop/color_lightness_call.cmd b/code/oop/color_lightness_call.cmd deleted file mode 100755 index 40b1ccf..0000000 --- a/code/oop/color_lightness_call.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> purple = Color() ->>> purple.red = 255 ->>> purple.green = 0 ->>> purple.blue = 255 ->>> purple.lightness() -0.5 diff --git a/code/oop/color_lightness_func.py b/code/oop/color_lightness_func.py deleted file mode 100755 index 8716206..0000000 --- a/code/oop/color_lightness_func.py +++ /dev/null @@ -1,6 +0,0 @@ -def lightness(color): - '''Return the lightness of color.''' - - strongest = max(color.red, color.green, color.blue) - weakest = min(color.red, color.green, color.blue) - return 0.5 * (strongest + weakest) / 255 diff --git a/code/oop/color_lightness_method.py b/code/oop/color_lightness_method.py deleted file mode 100755 index 84a2974..0000000 --- a/code/oop/color_lightness_method.py +++ /dev/null @@ -1,9 +0,0 @@ -class Color(object): - '''An RGB color, with red, green and blue components.''' - - def lightness(self): - '''Calculate the lightness of this color.''' - - strongest = max(self.red, self.green, self.blue) - weakest = min(self.red, self.green, self.blue) - return 0.5 * (strongest + weakest) / 255 diff --git a/code/oop/color_obj.cmd b/code/oop/color_obj.cmd deleted file mode 100755 index f1c91a7..0000000 --- a/code/oop/color_obj.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> black = Color() \ No newline at end of file diff --git a/code/oop/color_print.cmd b/code/oop/color_print.cmd deleted file mode 100755 index 827b7ab..0000000 --- a/code/oop/color_print.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> purple = Color(128, 0, 128) ->>> print purple -(128, 0, 128) diff --git a/code/oop/color_print_parts.cmd b/code/oop/color_print_parts.cmd deleted file mode 100755 index cc68f1d..0000000 --- a/code/oop/color_print_parts.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> black.red -0 ->>> black.green -0 ->>> black.blue -0 \ No newline at end of file diff --git a/code/oop/color_purple.cmd b/code/oop/color_purple.cmd deleted file mode 100755 index 52b0757..0000000 --- a/code/oop/color_purple.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> purple = Color() ->>> purple.red = 128 ->>> purple.green = 0 ->>> purple.blue = 128 diff --git a/code/oop/color_purple_init.cmd b/code/oop/color_purple_init.cmd deleted file mode 100755 index 2b2a806..0000000 --- a/code/oop/color_purple_init.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> purple = Color(128, 0, 128) \ No newline at end of file diff --git a/code/oop/color_purple_no_str.cmd b/code/oop/color_purple_no_str.cmd deleted file mode 100755 index 2a2186a..0000000 --- a/code/oop/color_purple_no_str.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> purple = Color(128, 0, 128) ->>> print purple - \ No newline at end of file diff --git a/code/oop/color_show_raw.cmd b/code/oop/color_show_raw.cmd deleted file mode 100755 index e238793..0000000 --- a/code/oop/color_show_raw.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> black -<__main__.Color object at 0xb7dbd24c> diff --git a/code/oop/color_simple.py b/code/oop/color_simple.py deleted file mode 100755 index b7d8976..0000000 --- a/code/oop/color_simple.py +++ /dev/null @@ -1,3 +0,0 @@ -class Color(object): - '''An RGB color, with red, green and blue components.''' - pass diff --git a/code/oop/color_str.py b/code/oop/color_str.py deleted file mode 100755 index 157a307..0000000 --- a/code/oop/color_str.py +++ /dev/null @@ -1,16 +0,0 @@ -class Color(object): - '''An RGB color, with red, green and blue components.''' - - def __init__(self, r, g, b): - '''A new color with red value r, green value g, and blue value b. All - components are integers in the range 0-255.''' - - self.red = r - self.green = g - self.blue = b - - def __str__(self): - '''Return a string representation of this Color in the form of an RGB - tuple.''' - - return '(%s, %s, %s)' % (self.red, self.green, self.blue) diff --git a/code/oop/line_counter.py b/code/oop/line_counter.py deleted file mode 100755 index bab8641..0000000 --- a/code/oop/line_counter.py +++ /dev/null @@ -1,8 +0,0 @@ -def non_blank_lines(thing): - '''Return the number of non-blank lines in thing.''' - - count = 0 - for line in thing: - if line.strip(): - count += 1 - return count diff --git a/code/oop/molecule.py b/code/oop/molecule.py deleted file mode 100755 index 6b1d344..0000000 --- a/code/oop/molecule.py +++ /dev/null @@ -1,62 +0,0 @@ -from atom import Atom - -#START:init -class Molecule(object): - '''A molecule with a name and a list of Atoms.''' - def __init__(self, name): - '''Create a Compound named name with no Atoms.''' - self.name = name - self.atoms = [] - def add(self, a): - '''Add Atom a to my list of Atoms.''' - self.atoms.append(a) -#END:init - - #START:translate - def translate(self, x, y, z): - '''Move this Compound, including all Atoms, by (x, y, z).''' - - for atom in self.atoms: - atom.translate(x, y, z) - #END:translate - - #START:str - def __repr__(self): - '''Return a string representation of this Molecule in this format: - Molecule("NAME", (ATOM1, ATOM2, ...)) - ''' - res = '' - for atom in self.atoms: - res = res + repr(atom) + ', ' - # Strip off the last comma. - res = res[:-2] - return 'Molecule("%s", (%s))' % (self.name, res) - def __str__(self): - '''Return a string representation of this Molecule in this format: - (NAME, (ATOM1, ATOM2, ...)) - ''' - res = '' - for atom in self.atoms: - res = res + str(atom) + ', ' - # Strip off the last comma. - res = res[:-2] - return '(%s, (%s))' % (self.name, res) - #END:str - - -if __name__ == '__main__': - #START:ammonia - ammonia = Molecule("AMMONIA") - ammonia.add(Atom(1, "N", 0.257, -0.363, 0.0)) - ammonia.add(Atom(2, "H", 0.257, 0.727, 0.0)) - ammonia.add(Atom(3, "H", 0.771, -0.727, 0.890)) - ammonia.add(Atom(4, "H", 0.771, -0.727, -0.890)) - ammonia.translate(0, 0, 0.2) - #END:ammonia - #START:test - assert ammonia.atoms[0].center[0] == 0.257 - assert ammonia.atoms[0].center[1] == -0.363 - assert ammonia.atoms[0].center[2] == 0.2 - #END:test - print repr(ammonia) - print ammonia diff --git a/code/oop/multimol_2.py b/code/oop/multimol_2.py deleted file mode 100755 index e5dbd4e..0000000 --- a/code/oop/multimol_2.py +++ /dev/null @@ -1,28 +0,0 @@ -from molecule import Molecule -from atom import Atom - -def read_molecule(r): - '''Read a single molecule from reader r and return it, - or return None to signal end of file.''' - - # If there isn't another line, we're at the end of the file. - line = r.readline() - if not line: - return None - - # Name of the molecule: "COMPND name" - key, name = line.split() - - # Other lines are either "END" or "ATOM num kind x y z" - molecule = Molecule(name) - reading = True - - while reading: - line = r.readline() - if line.startswith('END'): - reading = False - else: - key, num, kind, x, y, z = line.split() - molecule.add(Atom(num, kind, float(x), float(y), float(z))) - - return molecule diff --git a/code/oop/organism.py b/code/oop/organism.py deleted file mode 100755 index e647b1c..0000000 --- a/code/oop/organism.py +++ /dev/null @@ -1,28 +0,0 @@ -class Organism(object): - '''A thing that lives in a tide pool.''' - - def __init__(self, name, x, y): - '''A living thing that is at location (x,y) in the tide pool.''' - - self.name = name - self.x = x - self.y = y - - def __str__(self): - '''Return a string representation of this Organism.''' - - return '(%s, [%s, %s])' % (self.name, self.x, self.y) - - def can_eat(self, food): - '''Report whether this Organism can eat the given food. - Since we don't know anything about what a generic organism - eats, this always returns False.''' - - return False - - def move(self): - '''Ask the organism to move. By default, this does nothing, - since we don't know anything about how fast or how far a - generic organism would move.''' - - return diff --git a/code/oop/rectangle_corners.py b/code/oop/rectangle_corners.py deleted file mode 100755 index 7f0e389..0000000 --- a/code/oop/rectangle_corners.py +++ /dev/null @@ -1,23 +0,0 @@ -class Rectangle(object): - '''Represent a rectangular section of an image.''' - - def __init__(self, x0, y0, x1, y1): - '''Create a rectangle with non-zero area. (x0,y0) is the - lower left corner, (x1,y1) the upper right corner.''' - - self.x0 = x0 - self.y0 = y0 - self.x1 = x1 - self.y1 = y1 - - def area(self): - '''Return the area of the rectangle.''' - - return (self.x1 - self.x0) * (self.y1 - self.y0) - - def contains(self, x, y): - '''Return True is (x,y) point is inside a rectangle, - and False otherwise.''' - - return (self.x0 <= x <= self.x1) and \ - (self.y0 <= y <= self.y1) diff --git a/code/oop/rectangle_corners_enc.py b/code/oop/rectangle_corners_enc.py deleted file mode 100755 index 15833ba..0000000 --- a/code/oop/rectangle_corners_enc.py +++ /dev/null @@ -1,32 +0,0 @@ -class Rectangle(object): - '''Represent a rectangular section of an image.''' - - def __init__(self, x0, y0, x1, y1): - ...as before... - - def area(self): - ...as before... - - def contains(self, x, y): - ...as before... - - def get_min_x(self): - '''Return the minimum X coordinate.''' - - return self.x0 - - def get_min_y(self): - '''Return the minimum Y coordinate.''' - - return self.y0 - - - def get_max_x(self): - '''Return the maximum X coordinate.''' - - return self.x1 - - def get_max_y(self): - '''Return the maximum Y coordinate.''' - - return self.y1 diff --git a/code/oop/rectangle_size.py b/code/oop/rectangle_size.py deleted file mode 100755 index fd1a0d7..0000000 --- a/code/oop/rectangle_size.py +++ /dev/null @@ -1,22 +0,0 @@ -class Rectangle(object): - '''Represent a rectangular section of an image.''' - - def __init__(self, x0, y0, width, height): - '''Create a rectangle with non-zero area. (x0,y0) is the - lower left corner, width and height the X and Y extent.''' - - self.x0 = x0 - self.y0 = y0 - self.width = width - self.height = height - - def area(self): - '''Return the area of the rectangle.''' - - return self.width * self.height - def contains(self, x, y): - '''Return True if (x,y) point is inside a rectangle, - and False otherwise.''' - - return (self.x0 <= x) and (x <= self.x0 + width) and \ - (self.y0 <= y) and (y <= self.y0 + height) diff --git a/code/oop/rectangle_size_enc.py b/code/oop/rectangle_size_enc.py deleted file mode 100755 index 85f4d67..0000000 --- a/code/oop/rectangle_size_enc.py +++ /dev/null @@ -1,31 +0,0 @@ -class Rectangle(object): - '''Represent a rectangular section of an image.''' - - def __init__(self, x0, y0, width, height): - ...as before... - - def area(self): - ...as before... - - def contains(self, x, y): - ...as before... - - def get_min_x(self): - '''Return the minimum X coordinate.''' - - return self.x0 - - def get_min_y(self): - '''Return the minimum Y coordinate.''' - - return self.y0 - - def get_max_x(self): - '''Return the maximum X coordinate.''' - - return self.x0 + width - - def get_max_y(self): - '''Return the maximum Y coordinate.''' - - return self.y0 + height diff --git a/code/oop/yellow_create_error.cmd b/code/oop/yellow_create_error.cmd deleted file mode 100755 index 93cbdbb..0000000 --- a/code/oop/yellow_create_error.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> yellow = Color() ->>> yellow.red = 128 ->>> yellow.green = 128 diff --git a/code/oop/yellow_lightness_fail.cmd b/code/oop/yellow_lightness_fail.cmd deleted file mode 100755 index 8f16600..0000000 --- a/code/oop/yellow_lightness_fail.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> yellow.lightness() -Traceback (most recent call last): - File "", line 1, in - File "", line 3, in lightness -AttributeError: 'Color' object has no attribute 'blue' diff --git a/code/searchsort/binary_search.py b/code/searchsort/binary_search.py deleted file mode 100755 index 4b0f953..0000000 --- a/code/searchsort/binary_search.py +++ /dev/null @@ -1,19 +0,0 @@ -def binary_search(v, L): - """Return the index of the leftmost occurrence of v in list L, or -1 if - v is not in L.""" - - # Mark the left and right indices of the unknown section. - i = 0 - j = len(L) - 1 - - while i != j + 1: - m = (i + j) / 2 - if L[m] < v: - i = m + 1 - else: - j = m - 1 - - if 0 <= i < len(L) and L[i] == v: - return i - else: - return -1 diff --git a/code/searchsort/binary_test.py b/code/searchsort/binary_test.py deleted file mode 100755 index 00bde41..0000000 --- a/code/searchsort/binary_test.py +++ /dev/null @@ -1,38 +0,0 @@ -'''Test binary search.''' - -import nose -from binary_search import binary_search - -# The list to search with. -VALUES = [1, 3, 4, 4, 5, 7, 9, 10] - -def test_first(): - '''Test a value at the beginning of the list.''' - assert binary_search(1, VALUES) == 0 - -def test_duplicate(): - '''Test a duplicate value.''' - assert binary_search(4, VALUES) == 2 - -def test_middle(): - '''Test searching for the middle value.''' - assert binary_search(5, VALUES) == 4 - -def test_last(): - '''Test searching for the last value.''' - assert binary_search(10, VALUES) == 7 - -def test_missing_start(): - '''Test searching for a missing value at the start.''' - assert binary_search(-3, VALUES) == -1 - -def test_missing_middle(): - '''Test searching for a missing value in the middle.''' - assert binary_search(2, VALUES) == -1 - -def test_missing_end(): - '''Test searching for a missing value at the end.''' - assert binary_search(11, VALUES) == -1 - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/searchsort/binsort.py b/code/searchsort/binsort.py deleted file mode 100755 index 80b8c63..0000000 --- a/code/searchsort/binsort.py +++ /dev/null @@ -1,8 +0,0 @@ -import bisect - -def bin_sort(values): - '''Sort values, creating a new list.''' - result = [] - for v in values: - bisect.insort_left(result, v) - return result diff --git a/code/searchsort/binsort_broken.py b/code/searchsort/binsort_broken.py deleted file mode 100755 index bafa8da..0000000 --- a/code/searchsort/binsort_broken.py +++ /dev/null @@ -1,6 +0,0 @@ -import bisect - -def bin_sort(values): - '''Sort values in place. THIS VERSION IS FLAWED''' - for i in range(1, len(values)): - bisect.insort_left(values, values[i], 0, i) diff --git a/code/searchsort/binsort_broken_test.cmd b/code/searchsort/binsort_broken_test.cmd deleted file mode 100755 index f94f35d..0000000 --- a/code/searchsort/binsort_broken_test.cmd +++ /dev/null @@ -1,11 +0,0 @@ ->>> from binsort_broken import bin_sort ->>> tests = [ [], [1], [1, 2], [2, 1] ] ->>> for t in tests: -... print t, '->', -... bin_sort(t) -... print t -... -[] -> [] -[1] -> [1] -[1, 2] -> [1, 2, 2] -[2, 1] -> [1, 2, 1] diff --git a/code/searchsort/index_help.txt b/code/searchsort/index_help.txt deleted file mode 100755 index d7104af..0000000 --- a/code/searchsort/index_help.txt +++ /dev/null @@ -1,2 +0,0 @@ -index(...) - L.index(value, [start, [stop]]) -> integer -- return first index of value diff --git a/code/searchsort/linear_search_1.py b/code/searchsort/linear_search_1.py deleted file mode 100755 index c2d433f..0000000 --- a/code/searchsort/linear_search_1.py +++ /dev/null @@ -1,8 +0,0 @@ -def linear_search(v, L): - '''Return the index of the first occurrence of v in list L, or return len(L) - if v is not in L.''' - i = 0 - # Keep going until we reach the end of L or until we find v. - while i != len(L) and L[i] != v: - i = i + 1 - return i diff --git a/code/searchsort/linear_search_2.py b/code/searchsort/linear_search_2.py deleted file mode 100755 index 67c4ec0..0000000 --- a/code/searchsort/linear_search_2.py +++ /dev/null @@ -1,10 +0,0 @@ -def linear_search(v, L): - '''Return the index of the first occurrence of v in list L, or return len(L) - if v is not in L.''' - - i = 0 - for value in L: - if value == v: - return i - i += 1 - return len(L) \ No newline at end of file diff --git a/code/searchsort/linear_search_3.py b/code/searchsort/linear_search_3.py deleted file mode 100755 index 691fd6f..0000000 --- a/code/searchsort/linear_search_3.py +++ /dev/null @@ -1,16 +0,0 @@ -def linear_search(v, L): - '''Return the index of the first occurrence of v in list L, or return len(L) - if v is not in L.''' - - # Add the sentinel. - L.append(v) - i = 0 - - # Keep going until we find v. - while L[i] != v: - i = i + 1 - - # Remove the sentinel. - L.pop() - - return i diff --git a/code/searchsort/linear_time_1.py b/code/searchsort/linear_time_1.py deleted file mode 100755 index e4adcd7..0000000 --- a/code/searchsort/linear_time_1.py +++ /dev/null @@ -1,37 +0,0 @@ -import time -import linear_search_1 -import linear_search_2 -import linear_search_3 - -def time_it(search, v, L): - '''Time how long it takes to run function search to find value v in list L.''' - - t1 = time.time() - search(v, L) - t2 = time.time() - - return (t2 - t1) * 1000. - -def print_times(v, L): - '''Print the number of milliseconds it takes for linear_search(v, L) - to run for list.index, basic linear search, the for loop linear search, - and sentinel search.''' - - # Get list.index's running time. - t1 = time.time() - L.index(v) - t2 = time.time() - index_time = (t2 - t1) * 1000. - # Get the other three running times. - basic_time = time_it(linear_search_1.linear_search, v, L) - for_time = time_it(linear_search_2.linear_search, v, L) - sentinel_time = time_it(linear_search_3.linear_search, v, L) - - print "%d\t%.02f\t%.02f\t%.02f\t%.02f" % \ - (v, basic_time, for_time, sentinel_time, index_time) - -L = range(1000001) -linear_search_1.linear_search(10, L) -print_times(10, L) -print_times(500000, L) -print_times(1000000, L) diff --git a/code/searchsort/merge.py b/code/searchsort/merge.py deleted file mode 100755 index 632bc9a..0000000 --- a/code/searchsort/merge.py +++ /dev/null @@ -1,22 +0,0 @@ -def merge(L1, L2): - """Merge sorted lists L1 and L2 and return the result.""" - - newL = [] - i1 = 0 - i2 = 0 - - # For each pair of items L1[1], L2[i2], copy the smaller into newL. - while i1 != len(L1) and i2 != len(L2): - if L1[i1] <= L2[i2]: - newL.append(L1[i1]) - i1 += 1 - else: - newL.append(L2[i2]) - i2 += 1 - - # Gather any leftover items from the two sections. - # Note that one of them will be empty because of the loop condition. - newL.extend(L1[i1:]) - newL.extend(L2[i2:]) - - return newL diff --git a/code/searchsort/mergesort_alg.py b/code/searchsort/mergesort_alg.py deleted file mode 100755 index 8989412..0000000 --- a/code/searchsort/mergesort_alg.py +++ /dev/null @@ -1,64 +0,0 @@ -def merge(L1, L2): - """Merge sorted lists L1 and L2 and return the result.""" - - newL = [] - i1 = 0 - i2 = 0 - - # For each pair of items L1[1], L2[i2], copy the smaller into newL. - while i1 != len(L1) and i2 != len(L2): - if L1[i1] <= L2[i2]: - newL.append(L1[i1]) - i1 += 1 - else: - newL.append(L2[i2]) - i2 += 1 - - # Gather any leftover items from the two sections. - # Note that one of them will be empty because of the loop condition. - newL.extend(L1[i1:]) - newL.extend(L2[i2:]) - - return newL - - -def mergesort(L): - """Sort L in increasing order.""" - - # Make a list of 1-item lists so that we can start merging. - workspace = [] - for i in range(len(L)): - workspace.append([L[i]]) - - # The next two lists to merge are workspace[i] and workspace[i + 1]. - i = 0 - - # As long as there are at least two more lists to merge, merge them. - while i < len(workspace) - 1: - L1 = workspace[i] - L2 = workspace[i + 1] - newL = merge(L1, L2) - workspace.append(newL) - i += 2 - - # Copy the result back into L. - if len(workspace) != 0: - L[:] = workspace[-1][:] - - -if __name__ == '__main__': - - L = [] - print "befor", L - mergesort(L) - print "after", L - - L = [1] - print "befor", L - mergesort(L) - print "after", L - - L = [5, 4, 2, 3, 6, 1] - print "befor", L - mergesort(L) - print "after", L diff --git a/code/searchsort/mergesort_function.py b/code/searchsort/mergesort_function.py deleted file mode 100755 index 4536af4..0000000 --- a/code/searchsort/mergesort_function.py +++ /dev/null @@ -1,22 +0,0 @@ -def mergesort(L): - """Sort L.""" - - # Make a list of 1-item lists so that we can start merging. - workspace = [] - for i in range(len(L)): - workspace.append([L[i]]) - - # The next two lists to merge are workspace[i] and workspace[i + 1]. - i = 0 - - # As long as there are at least two more lists to merge, merge them. - while i < len(workspace) - 1: - L1 = workspace[i] - L2 = workspace[i + 1] - newL = merge(L1, L2) - workspace.append(newL) - i += 2 - - # Copy the result back into L. - if len(workspace) != 0: - L[:] = workspace[-1][:] diff --git a/code/searchsort/mergesort_header.py b/code/searchsort/mergesort_header.py deleted file mode 100755 index 7c21194..0000000 --- a/code/searchsort/mergesort_header.py +++ /dev/null @@ -1,2 +0,0 @@ -def mergesort(L): - """Sort L in increasing order.""" diff --git a/code/searchsort/mergesort_make_list.py b/code/searchsort/mergesort_make_list.py deleted file mode 100755 index e517d11..0000000 --- a/code/searchsort/mergesort_make_list.py +++ /dev/null @@ -1,4 +0,0 @@ -# Make a list of 1-item lists so that we can start merging. -workspace = [] -for i in range(len(L)): - workspace.append([L[i]]) diff --git a/code/searchsort/mergesort_test.py b/code/searchsort/mergesort_test.py deleted file mode 100755 index 6c74056..0000000 --- a/code/searchsort/mergesort_test.py +++ /dev/null @@ -1,62 +0,0 @@ -from ms import mergesort, merge -import nose - -def run_mergesort(original, expected): - '''Sort list original and compare it to list expected.''' - mergesort(original) - assert original == expected - -def run_merge(L1, L2, expected): - '''Merge list original[b1:e1] with original[b2:e2] and compare it to list - expected.''' - result = merge(L1, L2) - assert result == expected - -def test_merge_empty(): - '''Test merging a 0-item list.''' - run_merge([], [], []) - -def test_merge_one(): - '''Test merging a 1-item list and a 1-item list.''' - run_merge([2], [1], [1, 2]) - -def test_merge_one_two(): - '''Test merging a 2-item list and a 1-item list.''' - L = [1, 3, 2] - run_merge([1, 3], [2], [1, 2, 3]) - -def test_merge_two_two(): - '''Test merging a 2-item list and a 2-item list.''' - run_merge([1, 3], [2, 4], [1, 2, 3, 4]) - -def test_merge_two_two_same(): - '''Test merging a 2-item list and a 2-item list where they have common - elements.''' - run_merge([1, 3], [1, 3], [1, 1, 3, 3]) - -def test_empty(): - '''Test sorting empty list.''' - run_mergesort([], []) - -def test_one(): - '''Test sorting a list of one value.''' - run_mergesort([1], [1]) - -def test_two_ordered(): - '''Test sorting an already-sorted list of two values.''' - run_mergesort([1, 2], [1, 2]) - -def test_two_reversed(): - '''Test sorting a reverse-ordered list of two values.''' - run_mergesort([2, 1], [1, 2]) - -def test_three_identical(): - '''Test sorting a list of three equal values.''' - run_mergesort([3, 3, 3], [3, 3, 3]) - -def test_three_split(): - '''Test sorting a list with an odd value out.''' - run_mergesort([3, 0, 3], [0, 3, 3]) - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/searchsort/ms.py b/code/searchsort/ms.py deleted file mode 100755 index c235779..0000000 --- a/code/searchsort/ms.py +++ /dev/null @@ -1,64 +0,0 @@ -def merge(L1, L2): - """Merge sorted lists L1 and L2 and return the result.""" - - newL = [] - i1 = 0 - i2 = 0 - - # For each pair of items L1[1], L2[i2], copy the smaller into newL. - while i1 != len(L1) and i2 != len(L2): - if L1[i1] <= L2[i2]: - newL.append(L1[i1]) - i1 += 1 - else: - newL.append(L2[i2]) - i2 += 1 - - # Gather any leftover items from the two sections. - # Note that one of them will be empty because of the loop condition. - newL.extend(L1[i1:]) - newL.extend(L2[i2:]) - - return newL - - -def mergesort(L): - """Sort L.""" - - # Make a list of 1-item lists so that we can start merging. - workspace = [] - for i in range(len(L)): - workspace.append([L[i]]) - - # The next two lists to merge are workspace[i] and workspace[i + 1]. - i = 0 - - # As long as there are at least two more lists to merge, merge them. - while i < len(workspace) - 1: - L1 = workspace[i] - L2 = workspace[i + 1] - newL = merge(L1, L2) - workspace.append(newL) - i += 2 - - # Copy the result back into L. - if len(workspace) != 0: - L[:] = workspace[-1][:] - - -if __name__ == '__main__': - - L = [] - print "befor", L - mergesort(L) - print "after", L - - L = [1] - print "befor", L - mergesort(L) - print "after", L - - L = [5, 4, 2, 3, 6, 1] - print "befor", L - mergesort(L) - print "after", L diff --git a/code/searchsort/sort1.py b/code/searchsort/sort1.py deleted file mode 100755 index 3078160..0000000 --- a/code/searchsort/sort1.py +++ /dev/null @@ -1,6 +0,0 @@ -def find_largest(N, L): - """Return the N largest values in L in order from smallest to largest.""" - - copy = L[:] - copy.sort() - return copy[:N] diff --git a/code/searchsort/sort2.py b/code/searchsort/sort2.py deleted file mode 100755 index d889dec..0000000 --- a/code/searchsort/sort2.py +++ /dev/null @@ -1,9 +0,0 @@ -def selection_sort(L): - """Reorder the items in L from smallest to largest.""" - - i = 0 - while i != len(L): - # Find the index of the smallest item in L[i:]. - # Swap that smallest item with L[i]. - i = i + 1 - diff --git a/code/searchsort/sort3.py b/code/searchsort/sort3.py deleted file mode 100755 index 7a4143e..0000000 --- a/code/searchsort/sort3.py +++ /dev/null @@ -1,8 +0,0 @@ -def selection_sort(L): - """Reorder the values in L from smallest to largest.""" - - i = 0 - while i != len(L): - # Find the index of the smallest item in L[i:]. - L[i], L[smallest] = L[smallest], L[i] - i = i + 1 diff --git a/code/searchsort/sort4.py b/code/searchsort/sort4.py deleted file mode 100755 index 4837591..0000000 --- a/code/searchsort/sort4.py +++ /dev/null @@ -1,22 +0,0 @@ -def selection_sort(L): - """Reorder the values in L from smallest to largest.""" - - i = 0 - while i != len(L): - smallest = find_min(L, i) - L[i], L[smallest] = L[smallest], L[i] - i = i + 1 - -def find_min(L, b): - """Return the index of the smallest value in L[b:].""" - - smallest = b # The index of the smallest so far. - i = b + 1 - while i != len(L): - if L[i] < L[smallest]: - # We found a smaller item at L[i]. - smallest = i - - i = i + 1 - - return smallest diff --git a/code/searchsort/sort4test.py b/code/searchsort/sort4test.py deleted file mode 100755 index 2258b53..0000000 --- a/code/searchsort/sort4test.py +++ /dev/null @@ -1,34 +0,0 @@ -from sort4 import selection_sort -import nose - -def run_test(original, expected): - '''Sort list original and compare it to list expected.''' - selection_sort(original) - assert original == expected - -def test_empty(): - '''Test sorting empty list.''' - run_test([], []) - -def test_one(): - '''Test sorting a list of one value.''' - run_test([1], [1]) - -def test_two_ordered(): - '''Test sorting an already-sorted list of two values.''' - run_test([1, 2], [1, 2]) - -def test_two_reversed(): - '''Test sorting a reverse-ordered list of two values.''' - run_test([2, 1], [1, 2]) - -def test_three_identical(): - '''Test sorting a list of three equal values.''' - run_test([3, 3, 3], [3, 3, 3]) - -def test_three_split(): - '''Test sorting a list with an odd value out.''' - run_test([3, 0, 3], [0, 3, 3]) - -if __name__ == '__main__': - nose.runmodule() diff --git a/code/searchsort/sort5.py b/code/searchsort/sort5.py deleted file mode 100755 index f358373..0000000 --- a/code/searchsort/sort5.py +++ /dev/null @@ -1,7 +0,0 @@ -def insertion_sort(L): - """Reorder the values in L from smallest to largest.""" - - i = 0 - while i != len(L): - # Insert L[i] where it belongs in L[0:i+1]. - i = i + 1 diff --git a/code/searchsort/sort7.py b/code/searchsort/sort7.py deleted file mode 100755 index 2566c4d..0000000 --- a/code/searchsort/sort7.py +++ /dev/null @@ -1,21 +0,0 @@ -def insertion_sort(L): - """Reorder the values in L from smallest to largest.""" - - i = 0 - while i != len(L): - insert(L, i) - i = i + 1 - -def insert(L, b): - """Insert L[b] where it belongs in L[0:b + 1]; - L[0:b - 1] must already be sorted.""" - - # Find where to insert L[b] by searching backwards from L[b] for a smaller item. - i = b - while i != 0 and L[i - 1] >= L[b]: - i = i - 1 - - # Move L[b] to index i, shifting the following values to the right. - value = L[b] - del L[b] - L.insert(i, value) diff --git a/code/searchsort/sort_time.py b/code/searchsort/sort_time.py deleted file mode 100755 index 654a576..0000000 --- a/code/searchsort/sort_time.py +++ /dev/null @@ -1,29 +0,0 @@ -import time -from sort4 import selection_sort -from sort7 import insertion_sort -from ms import mergesort - -def built_in(L): - '''Call list.sort --- we need our own function to do this - so that we can treat it as we treat our own sorts.''' - L.sort() - -def print_times(L): - '''Print the number of milliseconds it takes for selection sort - and insertion sort to run.''' - print len(L), - for func in (selection_sort, insertion_sort, mergesort, built_in): - if func in (selection_sort, insertion_sort) and len(L) > 4000: - continue - - L_copy = L[:] - t1 = time.time() - func(L_copy) - t2 = time.time() - print "\t%.1f" % ((t2 - t1) * 1000.), - print - -for list_size in [10, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 40000, 80000]: - L = range(list_size) - L.reverse() - print_times(L) diff --git a/code/setdict/badkey.cmd b/code/setdict/badkey.cmd deleted file mode 100755 index 469acac..0000000 --- a/code/setdict/badkey.cmd +++ /dev/null @@ -1,7 +0,0 @@ ->>> birds = {'canada goose' : 3, 'northern fulmar' : 1} ->>> birds['canada goose'] -3 ->>> birds['long-tailed jaeger'] -Traceback (most recent call last): - File "", line 1, in ? -KeyError: 'long-tailed jaeger' diff --git a/code/setdict/birdwatching.py b/code/setdict/birdwatching.py deleted file mode 100755 index ec7559e..0000000 --- a/code/setdict/birdwatching.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -# Find the different bird types observed. -birds = set() -for filename in sys.argv[1:]: - infile = open(filename, 'r') - for line in infile: - name = line.strip() - birds.add(name) - infile.close() - -# Print the birds. -for b in birds: - print b diff --git a/code/setdict/birdwatching.txt b/code/setdict/birdwatching.txt deleted file mode 100755 index 4305f7a..0000000 --- a/code/setdict/birdwatching.txt +++ /dev/null @@ -1,8 +0,0 @@ -canada goose -canada goose -long-tailed jaeger -canada goose -snow goose -canada goose -canada goose -northern fulmar diff --git a/code/setdict/countbirds1.py b/code/setdict/countbirds1.py deleted file mode 100755 index 294a185..0000000 --- a/code/setdict/countbirds1.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -# Count all the birds. -count = {} -for filename in sys.argv[1:]: - infile = open(filename, 'r') - for line in infile: - name = line.strip() - if name in count: - count[name] = count[name] + 1 - else: - count[name] = 1 - - infile.close() -# Print. -for b in count: - print b, count[b] diff --git a/code/setdict/countbirds2.py b/code/setdict/countbirds2.py deleted file mode 100755 index c7491c1..0000000 --- a/code/setdict/countbirds2.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys - -# Count all the birds. -count = {} -for filename in sys.argv[1:]: - infile = open(filename, 'r') - for line in infile: - name = line.strip() - count[name] = count.get(name, 0) + 1 - infile.close() - -# Print. -keys = count.keys() -keys.sort() -for b in keys: - print b, count[b] diff --git a/code/setdict/countbirds3.py b/code/setdict/countbirds3.py deleted file mode 100755 index df7b8f8..0000000 --- a/code/setdict/countbirds3.py +++ /dev/null @@ -1,22 +0,0 @@ -import sys -# Count all the birds. -count = {} -for filename in sys.argv[1:]: - infile = open(filename, 'r') - for line in infile: - name = line.strip() - count[name] = count.get(name, 0) + 1 - infile.close() -# Invert the dictionary. -freq = {} -for (name, times) in count.items(): - if times in freq: - freq[times].append(name) - - else: - freq[times] = [name] -# Print. -for key in sorted(freq): - print key - for name in freq[key]: - print ' ', name diff --git a/code/setdict/countbirds4.py b/code/setdict/countbirds4.py deleted file mode 100755 index 75c8dc1..0000000 --- a/code/setdict/countbirds4.py +++ /dev/null @@ -1,24 +0,0 @@ -import sys - -# Count all the birds. -count = {} -for filename in sys.argv[1:]: - infile = open(filename, 'r') - for line in infile: - name = line.strip() - count[name] = count.get(name, 0) + 1 - infile.close() - -# Invert the dictionary. -freq = {} -for (name, times) in count.items(): - if times in freq: - freq[times].append(name) - else: - freq[times] = [name] - -# Print. -for key in sorted(freq): - print key - for name in freq[key]: - print ' ', name diff --git a/code/setdict/dict_of_dicts.py b/code/setdict/dict_of_dicts.py deleted file mode 100755 index b931462..0000000 --- a/code/setdict/dict_of_dicts.py +++ /dev/null @@ -1,21 +0,0 @@ -{ - 'jgoodall' : {'surname' : 'Goodall', - 'forename' : 'Jane', - 'born' : 1934, - 'died' : None, - 'notes' : 'primate researcher' - 'author' : ['In the Shadow of Man', 'The Chimpanzees of Gombe']}, - 'rfranklin' : {'surname' : 'Franklin', - 'forename' : 'Rosalind', - 'born' : 1920, - 'died' : 1957, - 'notes' : 'contributed to discovery of DNA'}, - - - 'rcarson' : {'surname' : 'Carson', - 'forename' : 'Rachel', - 'born' : 1907, - 'died' : 1964, - 'notes' : 'raised awareness of effects of DDT', - 'author' : ['Silent Spring']} -} diff --git a/code/setdict/dictdel.cmd b/code/setdict/dictdel.cmd deleted file mode 100755 index 2402db1..0000000 --- a/code/setdict/dictdel.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> birds = {'snow goose' : 33, 'eagle' : 9} ->>> del birds['snow goose'] ->>> birds -{'eagle' : 9} ->>> del birds['gannet'] -Traceback (most recent call last): - File "", line 1, in -KeyError: 'gannet' diff --git a/code/setdict/dictin.cmd b/code/setdict/dictin.cmd deleted file mode 100755 index 784bbe4..0000000 --- a/code/setdict/dictin.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> birds = {'eagle' : 999, 'snow goose' : 33} ->>> if 'eagle' in birds: -... print 'eagles have been seen' -... -eagles have been seen ->>> del birds['eagle'] ->>> if 'eagle' in birds: -... print 'oops: why are eagles still there?' -... diff --git a/code/setdict/dictmeth.out b/code/setdict/dictmeth.out deleted file mode 100755 index 77fd0aa..0000000 --- a/code/setdict/dictmeth.out +++ /dev/null @@ -1,7 +0,0 @@ -keys: ['Turing', 'Newton', 'Darwin'] -values: [1912, 1642, 1809] -items: [('Turing', 1912), ('Newton', 1642), ('Darwin', 1809)] -get: 1867 -after update: {'Curie': 1867, 'Darwin': 1809, 'Franklin': 1920, - 'Turing': 1912, 'Newton': 1642, 'Hopper': 1906} -after clear: {} diff --git a/code/setdict/dictmeth.py b/code/setdict/dictmeth.py deleted file mode 100755 index 0bc314d..0000000 --- a/code/setdict/dictmeth.py +++ /dev/null @@ -1,13 +0,0 @@ -scientists = {'Newton' : 1642, 'Darwin' : 1809, 'Turing' : 1912} - -print 'keys:', scientists.keys() -print 'values:', scientists.values() -print 'items:', scientists.items() -print 'get:', scientists.get('Curie', 1867) - -temp = {'Curie' : 1867, 'Hopper' : 1906, 'Franklin' : 1920} -scientists.update(temp) -print 'after update:', scientists - -scientists.clear() -print 'after clear:', scientists diff --git a/code/setdict/dictupdate.cmd b/code/setdict/dictupdate.cmd deleted file mode 100755 index b85f9b1..0000000 --- a/code/setdict/dictupdate.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> birds = {} ->>> birds['snow goose'] = 33 ->>> birds['eagle'] = 999 # oops ->>> birds -{'eagle' : 999, 'snow goose' : 33} ->>> birds['eagle'] = 9 ->>> birds -{'eagle' : 9, 'snow goose' : 33} diff --git a/code/setdict/hashcode.cmd b/code/setdict/hashcode.cmd deleted file mode 100755 index 8797a28..0000000 --- a/code/setdict/hashcode.cmd +++ /dev/null @@ -1,14 +0,0 @@ ->>> help(hash) -Help on built-in function hash in module __builtin__: - -hash(...) - hash(object) -> integer - - Return a hash value for the object. Two objects with the same - value have the same hash value. The reverse is not necessarily - true, but likely. - ->>> hash(123) -123 ->>> hash('123') # a string -1911471187 diff --git a/code/setdict/hashcode_seq.cmd b/code/setdict/hashcode_seq.cmd deleted file mode 100755 index ae011bb..0000000 --- a/code/setdict/hashcode_seq.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> hash((1, 2, 3)) --378539185 ->>> hash([1, 2, 3]) -Traceback (most recent call last): - File "", line 1, in -TypeError: list objects are unhashable diff --git a/code/setdict/listfordict.py b/code/setdict/listfordict.py deleted file mode 100755 index 8aaab0d..0000000 --- a/code/setdict/listfordict.py +++ /dev/null @@ -1,20 +0,0 @@ -import sys - -# Find all the birds. -birds = [] -for filename in sys.argv[1:]: - infile = open(filename, 'r') - # For each bird, find its entry and increment the count. - for line in infile: - name = line.strip() - found = False - for entry in birds: - if entry[0] == name: - entry[1] += 1 - found = True - if not found: - birds.append([name, 1]) - infile.close() -# Print. -for (name, count) in birds: - print name, count diff --git a/code/setdict/loop.cmd b/code/setdict/loop.cmd deleted file mode 100755 index 22c7a22..0000000 --- a/code/setdict/loop.cmd +++ /dev/null @@ -1,9 +0,0 @@ ->>> birds = {'canada goose' : 183, 'long-tailed jaeger' : 71, - 'snow goose' : 63, 'northern fulmar', 1} ->>> for x in birds: -... print x, birds[x] -... -'northern fulmar' 1 -'long-tailed jaeger' 71 -'canada goose' 183 -'snow goose' 63 diff --git a/code/setdict/setexamples.cmd b/code/setdict/setexamples.cmd deleted file mode 100755 index 7e20e6c..0000000 --- a/code/setdict/setexamples.cmd +++ /dev/null @@ -1,24 +0,0 @@ ->>> ten = set(range(10)) ->>> lows = set([0, 1, 2, 3, 4]) ->>> odds = set([1, 3, 5, 7, 9]) ->>> lows.add(9) ->>> lows -set([0, 1, 2, 3, 4, 9]) ->>> lows.difference(odds) -set([0, 2, 4]) ->>> lows.intersection(odds) -set([1, 3, 9]) ->>> lows.issubset(ten) -True ->>> lows.issuperset(odds) -False ->>> lows.remove(0) ->>> lows -set([1, 2, 3, 4, 9]) ->>> lows.symmetric_difference(odds) -set([2, 4, 5, 7]) ->>> lows.union(odds) -set([1, 2, 3, 4, 5, 7, 9]) ->>> lows.clear() ->>> lows -set([]) diff --git a/code/setdict/simpledict.cmd b/code/setdict/simpledict.cmd deleted file mode 100755 index 58d0753..0000000 --- a/code/setdict/simpledict.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> birds = {'canada goose' : 3, 'northern fulmar' : 1} ->>> birds -{'canada goose' : 3, 'northern fulmar' : 1} ->>> birds['northern fulmar'] -1 diff --git a/code/strings/adding_quotes.cmd b/code/strings/adding_quotes.cmd deleted file mode 100755 index 3698a70..0000000 --- a/code/strings/adding_quotes.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> 'She said, "That' + "'" + 's hard to read."' diff --git a/code/strings/adding_quotes_output.cmd b/code/strings/adding_quotes_output.cmd deleted file mode 100755 index 27cb466..0000000 --- a/code/strings/adding_quotes_output.cmd +++ /dev/null @@ -1 +0,0 @@ -'She said, "That\'s hard to read."' diff --git a/code/strings/concat.cmd b/code/strings/concat.cmd deleted file mode 100755 index 5982fa4..0000000 --- a/code/strings/concat.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 'Albert' 'Einstein' -'AlbertEinstein' diff --git a/code/strings/concat2.cmd b/code/strings/concat2.cmd deleted file mode 100755 index 415d450..0000000 --- a/code/strings/concat2.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> 'Albert' + ' Einstein' -'Albert Einstein' diff --git a/code/strings/concat3.cmd b/code/strings/concat3.cmd deleted file mode 100755 index afe2f16..0000000 --- a/code/strings/concat3.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> 'NH' + 3 -Traceback (most recent call last): - File "", line 1, in ? -TypeError: cannot concatenate 'str' and 'int' objects ->>> 9 + ' planets' -Traceback (most recent call last): - File "", line 1, in ? -TypeError: unsupported operand type(s) for +: 'int' and 'str' diff --git a/code/strings/concat4.cmd b/code/strings/concat4.cmd deleted file mode 100755 index 1ac77c1..0000000 --- a/code/strings/concat4.cmd +++ /dev/null @@ -1 +0,0 @@ ->>> '123' + 4 diff --git a/code/strings/concat5.cmd b/code/strings/concat5.cmd deleted file mode 100755 index 107b549..0000000 --- a/code/strings/concat5.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> '12' + str(34) + '56' -'123456' diff --git a/code/strings/concat_space.cmd b/code/strings/concat_space.cmd deleted file mode 100755 index 4a52f60..0000000 --- a/code/strings/concat_space.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 'Albert ' 'Einstein' -'Albert Einstein' ->>> 'Albert' ' Einstein' -'Albert Einstein' \ No newline at end of file diff --git a/code/strings/empty_string.cmd b/code/strings/empty_string.cmd deleted file mode 100755 index 1cdd580..0000000 --- a/code/strings/empty_string.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> '' -'' ->>> "Alan Turing" + '' -'Alan Turing' ->>> "" + 'Grace Hopper' -'Grace Hopper' diff --git a/code/strings/mismatched_quotes.cmd b/code/strings/mismatched_quotes.cmd deleted file mode 100755 index a60ff68..0000000 --- a/code/strings/mismatched_quotes.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> 'Charles Darwin" - File "", line 1 - 'Charles Darwin" - ^ -SyntaxError: EOL while scanning single-quoted string diff --git a/code/strings/multi1.cmd b/code/strings/multi1.cmd deleted file mode 100755 index 36f81cb..0000000 --- a/code/strings/multi1.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> 'one -Traceback (most recent call last): - File "", line 1, in -Could not execute because an error occurred: - EOL while scanning single-quoted string: , line 1, pos 4: - 'one \ No newline at end of file diff --git a/code/strings/multi2.cmd b/code/strings/multi2.cmd deleted file mode 100755 index c1c8b7f..0000000 --- a/code/strings/multi2.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> '''one -... two -... three''' -'one\ntwo\nthree' \ No newline at end of file diff --git a/code/strings/print.cmd b/code/strings/print.cmd deleted file mode 100755 index abf6c18..0000000 --- a/code/strings/print.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> print "The area of the circle is %f sq cm." % area -The area of the circle is 78.539750 sq cm. diff --git a/code/strings/print2.cmd b/code/strings/print2.cmd deleted file mode 100755 index 4cbd81e..0000000 --- a/code/strings/print2.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> rabbits = 17 ->>> cage = 10 ->>> print "%f rabbits are in cage #%d." % (rabbits, cage) -17.000000 rabbits are in cage #10. \ No newline at end of file diff --git a/code/strings/print3.cmd b/code/strings/print3.cmd deleted file mode 100755 index b00857a..0000000 --- a/code/strings/print3.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> print 1 + 1 -2 ->>> print "The Latin 'oryctolagus cuniculus' means 'domestic rabbit'." -The Latin 'oryctolagus cuniculus' means 'domestic rabbit'. diff --git a/code/strings/print4.cmd b/code/strings/print4.cmd deleted file mode 100755 index 79b53a7..0000000 --- a/code/strings/print4.cmd +++ /dev/null @@ -1,6 +0,0 @@ ->>> print 'In 1859, Charles Darwin revolutionized biology' -In 1859, Charles Darwin revolutionized biology ->>> print 'and our understanding of ourselves' -and our understanding of ourselves ->>> print 'by publishing "On the Origin of Species".' -by publishing "On the Origin of Species". diff --git a/code/strings/print5.cmd b/code/strings/print5.cmd deleted file mode 100755 index e3210b4..0000000 --- a/code/strings/print5.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> print 'one\ttwo\nthree\tfour' -one two -three four diff --git a/code/strings/print_multiline2.cmd b/code/strings/print_multiline2.cmd deleted file mode 100755 index 903124c..0000000 --- a/code/strings/print_multiline2.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> print rabbits, -17>>> diff --git a/code/strings/print_var.cmd b/code/strings/print_var.cmd deleted file mode 100755 index 5d01e27..0000000 --- a/code/strings/print_var.cmd +++ /dev/null @@ -1,3 +0,0 @@ ->>> area = 3.14159 * 5 * 5 ->>> print "The area of the circle is", area, "sq cm." -The area of the circle is 78.539750 sq cm. diff --git a/code/strings/raw_input_param.cmd b/code/strings/raw_input_param.cmd deleted file mode 100755 index 6006aa2..0000000 --- a/code/strings/raw_input_param.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> name = raw_input("Please enter a name: ") -Please enter a name: Darwin ->>> print name -Darwin diff --git a/code/strings/repeat.cmd b/code/strings/repeat.cmd deleted file mode 100755 index 9165ee5..0000000 --- a/code/strings/repeat.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 'AT' * 5 -'ATATATATAT' ->>> 4 * '-' -'----' diff --git a/code/strings/repeat2.cmd b/code/strings/repeat2.cmd deleted file mode 100755 index 8f654d4..0000000 --- a/code/strings/repeat2.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 'GC' * 0 -'' ->>> 'TATATATA' * -3 -'' diff --git a/code/strings/single_in_double.cmd b/code/strings/single_in_double.cmd deleted file mode 100755 index c4742f0..0000000 --- a/code/strings/single_in_double.cmd +++ /dev/null @@ -1,2 +0,0 @@ ->>> "that's better" -"that's better" diff --git a/code/strings/single_in_single.cmd b/code/strings/single_in_single.cmd deleted file mode 100755 index 19d7726..0000000 --- a/code/strings/single_in_single.cmd +++ /dev/null @@ -1,5 +0,0 @@ ->>> 'that's not going to work' - File "", line 1 - 'that's not going to work' - ^ -SyntaxError: invalid syntax diff --git a/code/strings/string.cmd b/code/strings/string.cmd deleted file mode 100755 index 1f3b995..0000000 --- a/code/strings/string.cmd +++ /dev/null @@ -1,4 +0,0 @@ ->>> 'Aristotle' -'Aristotle' ->>> "Isaac Newton" -'Isaac Newton' diff --git a/code/strings/user_input.cmd b/code/strings/user_input.cmd deleted file mode 100755 index a0b02d1..0000000 --- a/code/strings/user_input.cmd +++ /dev/null @@ -1,8 +0,0 @@ ->>> line = raw_input() -Galapagos Islands ->>> print line -Galapagos Islands ->>> line = raw_input() -123 ->>> print line * 2 -123123 \ No newline at end of file diff --git a/code/strings/user_input2.cmd b/code/strings/user_input2.cmd deleted file mode 100755 index 5ede965..0000000 --- a/code/strings/user_input2.cmd +++ /dev/null @@ -1,10 +0,0 @@ ->>> value = raw_input() -123 ->>> value = int(value) ->>> print value * 2 -246 ->>> value = float(raw_input()) -Galapagos -Traceback (most recent call last): - File "", line 1, in -ValueError: invalid literal for float(): Galapagos \ No newline at end of file diff --git a/imlist/test 2 copy 12.jpg b/imlist/test 2 copy 12.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/imlist/test 2 copy 12.jpg and /dev/null differ diff --git a/imlist/test 2 copy 13.jpg b/imlist/test 2 copy 13.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/imlist/test 2 copy 13.jpg and /dev/null differ diff --git a/imlist/test 2 copy 14.jpg b/imlist/test 2 copy 14.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/imlist/test 2 copy 14.jpg and /dev/null differ diff --git a/imlist/test 2 copy 15.jpg b/imlist/test 2 copy 15.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/imlist/test 2 copy 15.jpg and /dev/null differ diff --git a/imlist/test 2 copy 16.jpg b/imlist/test 2 copy 16.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/imlist/test 2 copy 16.jpg and /dev/null differ diff --git a/imlist/test 2 copy.jpg b/imlist/test 2 copy.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/imlist/test 2 copy.jpg and /dev/null differ diff --git a/imlist/test 2.jpg b/imlist/test 2.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/imlist/test 2.jpg and /dev/null differ diff --git a/imlist/test.jpg b/imlist/test.jpg deleted file mode 100755 index 5064ca7..0000000 Binary files a/imlist/test.jpg and /dev/null differ