Text copy of the code used in the review class... >>> from myro import * (c) 2006-2007 Institute for Personal Robots in Education [See http://www.roboteducation.org/ for more information] Myro version 2.8.14 is ready! >>> p = loadPicture("class.gif") >>> show(p) >>> >>> >>> for i in range(10): print i, "\t" 0 1 2 3 4 5 6 7 8 9 >>> for i in range(10): print "\t", i, "\t" 0 1 2 3 4 5 6 7 8 9 >>> for i in range(10): print "\t", i, "\t", 0 1 2 3 4 5 6 7 8 9 >>> for i in range(4): print "\t", i, "\t", 0 1 2 3 >>> for i in range(4): print "\t", i, "\n", 0 1 2 3 >>> for i in range(4): print "\t", i 0 1 2 3 >>> for i in range(4): print "\t", i , 0 1 2 3 >>> for i in range(4): for j in range(-4,1): print "i,j is:", i, j , print "" i,j is: 0 -4 i,j is: 0 -3 i,j is: 0 -2 i,j is: 0 -1 i,j is: 0 0 i,j is: 1 -4 i,j is: 1 -3 i,j is: 1 -2 i,j is: 1 -1 i,j is: 1 0 i,j is: 2 -4 i,j is: 2 -3 i,j is: 2 -2 i,j is: 2 -1 i,j is: 2 0 i,j is: 3 -4 i,j is: 3 -3 i,j is: 3 -2 i,j is: 3 -1 i,j is: 3 0 >>> for i in range(4): for j in range(-4,1): print "i,j is:", i, j, "\t", print "" i,j is: 0 -4 i,j is: 0 -3 i,j is: 0 -2 i,j is: 0 -1 i,j is: 0 0 i,j is: 1 -4 i,j is: 1 -3 i,j is: 1 -2 i,j is: 1 -1 i,j is: 1 0 i,j is: 2 -4 i,j is: 2 -3 i,j is: 2 -2 i,j is: 2 -1 i,j is: 2 0 i,j is: 3 -4 i,j is: 3 -3 i,j is: 3 -2 i,j is: 3 -1 i,j is: 3 0 >>> for i in range(4): for j in range(-4,1): print "i,j is:", i, j, "\t", print "" i,j is: 0 -4 i,j is: 0 -3 i,j is: 0 -2 i,j is: 0 -1 i,j is: 0 0 i,j is: 1 -4 i,j is: 1 -3 i,j is: 1 -2 i,j is: 1 -1 i,j is: 1 0 i,j is: 2 -4 i,j is: 2 -3 i,j is: 2 -2 i,j is: 2 -1 i,j is: 2 0 i,j is: 3 -4 i,j is: 3 -3 i,j is: 3 -2 i,j is: 3 -1 i,j is: 3 0 >>> >>> >>> >>> >>> >>> [4,5,6] [4, 5, 6] >>> (4,5,6) (4, 5, 6) >>> >>> >>> >>> "this is a test" 'this is a test' >>> >>> >>> >>> >>> >>> myDict = {} >>> >>> >>> myDict {} >>> myDict["test"] = 4 >>> >>> >>> >>> myDict[ [4,5] ] = 10 Traceback (most recent call last): File "", line 1, in myDict[ [4,5] ] = 10 TypeError: list objects are unhashable >>> >>> >>> >>> >>> >>> myDict[ (4,5) ] = 10 >>> >>> >>> >>> >>> >>> >>> myDict {'test': 4, (4, 5): 10} >>> >>> >>> >>> myDict["test"] 4 >>> >>> >>> myDict[(4,5)] 10 >>> >>> >>> myDict["hi"] Traceback (most recent call last): File "", line 1, in myDict["hi"] KeyError: 'hi' >>> >>> >>> >>> >>> >>> >>> myDict.get("hi", "default") 'default' >>> >>> >>> >>> >>> >>> >>> >>> >>> myDict.keys() ['test', (4, 5)] >>> myDict.values() [4, 10] >>> >>> >>> >>> >>> >>> >>> myfile = open("comment.txt", "r") >>> >>> >>> >>> myVar = myfile.read() >>> >>> >>> myVar '#This is a short comment in the style of code documentation.\n#All lines start with "#" marks and contain simple explanations\n# about code variables such as x, y, and z, and how those \n# variables should be used.\n' >>> >>> myfile.close() >>> >>> >>> myFile = open("comment.txt", "r") >>> >>> >>> oneLine = myFile.readline() >>> >>> >>> oneLine '#This is a short comment in the style of code documentation.\n' >>> >>> len(oneLine) 61 >>> twoLine = myFile.readline() >>> >>> >>> len(twoLine) 64 >>> >>> >>> print twoLine #All lines start with "#" marks and contain simple explanations >>> >>> >>> a = myfile.readline() Traceback (most recent call last): File "", line 1, in a = myfile.readline() ValueError: I/O operation on closed file >>> a = myFile.readline() >>> >>> >>> a '# about code variables such as x, y, and z, and how those \n' >>> len(a) 59 >>> b = myFile.readline() >>> len(b) 28 >>> >>> b '# variables should be used.\n' >>> c = myFile.readline() >>> len(c) 0 >>> >>> >>> c '' >>> >>> >>> myFile.close() >>> >>> >>> >>> myFile = open("comments.txt", "r") Traceback (most recent call last): File "", line 1, in myFile = open("comments.txt", "r") IOError: [Errno 2] No such file or directory: 'comments.txt' >>> >>> myFile = open("comment.txt", "r") >>> >>> >>> >>> lines = myFile.readlines() >>> >>> >>> >>> lines ['#This is a short comment in the style of code documentation.\n', '#All lines start with "#" marks and contain simple explanations\n', '# about code variables such as x, y, and z, and how those \n', '# variables should be used.\n'] >>> >>> len(lines) 4 >>> lines[3] '# variables should be used.\n' >>> lines[0] '#This is a short comment in the style of code documentation.\n' >>> >>> >>> >>> myFile = open("output.txt", "w") >>> >>> >>> myFile.write( "This is output text") >>> >>> >>> myFile.write("another string, with a newline \n") >>> myFile.write("a third string") >>> myFile.close() >>> >>> >>> show(p) >>> p = loadPicture("class.gif") >>> show(p) >>> pix = getPixel(p, 50,50) >>> >>> >>> pix >>> setGreen(pix, 255) >>> setRed(pix,0) >>> setBlue(pix,0) >>> show(p) >>> >>> >>> >>> allPixels = getPixels(p) >>> >>> >>> for pix in allPixels: setRed(pix,255) >>> show(p) >>> for x in range(50,100): pix = getPixel(p, x, 100) setRed(pix,0) setBlue(pix,0) setGreen(pix,0) >>> show(p) >>> p = loadPicture("class.gif") >>> for x in range(50,100): for y in range(50,100): pix = getPixel(p,x,y) setRed(pix,0) setGreen(pix,0) setBlue(pix,0) show(p) wait(0.01) >>> for x in range(50,100): for y in range(50,100): pix = getPixel(p,x,y) setRed(pix,0) setGreen(pix,0) setBlue(pix,0) show(p) wait(0.01) >>> p = loadPicture("class.gif") >>> for x in range(50,100): for y in range(50,100): pix = getPixel(p,x,y) setRed(pix,0) setGreen(pix,0) setBlue(pix,0) show(p) wait(0.01)