def grayScale(redWeight,greenWeight,blueWeight): pic=makePicture(pickAFile()) show(pic) for p in getPixels(pic): r = getRed(p)*redWeight #0.299 g = getGreen(p)*greenWeight #0.587 b = getBlue(p)*blueWeight #0.114 lum = r+g+b setColor(p,makeColor(lum,lum,lum)) repaint(pic)