Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Fall 2005 Midterm Review - Color-blind


redREMOVEDOut(picture)
for px in getPixels(picture):
green=getREMOVED(px)
red=getRed(px)
setREMOVED(px,(green+red)/2)
setRed(px,(green+red)/2)

look up. I forgot my colon for the first line, and my indentations aren't showing for some reason.
Make sure you remember your def at the beginning. -Student2042
def example():
   if (this.worked):
      print "I am indented and look like code"

type <code> before your code and </code> after it and it will take care of the indentations if you put them in.-Student2042



def redREMOVEDOut(picture):
   for px in getPixels(picture):
      green = getREMOVED(px)
      red = getRed(px)
      avg = (green + red)/2
   setREMOVED(px, avg)
   setRed(px, avg)

why wont that work?!?!
First add the colon to the end of line 2. Also, because your setREMOVED and setRed aren't part of the for loop, it'll only work for the bottom-right-hand pixel ONLY while leaving the rest of the picture unmodified. -Student1680


def redREMOVEDOut(picture):
   for px in getPixels(picture):
    green = getREMOVED(px)
    red = getRed(px)
    avg = (green + red)/2
    setREMOVED(px, avg)
    setRed(px, avg)

better??


mmhmm. -Student1680

def redREMOVEDOut(pict):
  for p in getPixels(pict):
    nred = getRed(p)
    ngreen = getREMOVED(p)
    setRed(p, (nred+ngreen)/2)
    setREMOVED(p, (nred+ngreen)/2)


Why doesn't this work?

Seems to work fine here. Perhaps you're not passing in a valid picture? -Student1680

why dont we repaint or return these?

You don't need to. Repaint is only for when you want the picture to be visible. Return is unnecessary for passed in objects. -Student1680

What is the function to make a number an integer? I realized that the problem was that when you average the red and green you sometimes get a float and need to make it into an integer. Otherwise, JES won't let you set a float to RGB values.

disregard that last entry



Link to this Page