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 2006 Midterm 1 Review - Color-blind

Questions?


I'd like to know if I'm on the right track or if it's correct. The program works but I'm not sure if it's correct.
def redREMOVEDOut(picture):
  for p in getPixels(picture):
    greenValue = getREMOVED(p)
    redValue = getREMOVED(p)
    setRed(p, (greenValue + redValue)/2)
    setREMOVED(p, (greenValue + redValue)/2)
  show(picture)
  return picture


Thanks!! Student4297

Looks good to me. Student1919

Why does JES return an error message when you try to perform this exact function?
charlie blackmon
REMOVEDs for me. Did you remember to load it? Colin Potts

shouldn't it be redValue = getRed instead of getREMOVED?
Aha! Colin Potts

Come on BB....Stacy Schwaiger

My bad yo... I meant the other way :D

why do you put return picture at the bottom?
For every function you write, it's a good idea to return the picture, so that it can be used later. Its optional unless specified in the question. So, in the exam, make sure whether we're asking you to show the picture or return the picture or both. - Bobby Mathew

def redREMOVEDOut(picture):
  for px in getPixels(picture):
    newRed=(getRed(px)+getREMOVED(px))/2
    newREMOVED=newRed
    newBlue=getBlue(px)
    setColor(px, makeColor(newRed, newREMOVED, newBlue))
  show(picture)
  return picture


I did it this way. Is there anything wrong with this, cause it works, but I was just wondering if there was anything technically wrong with it.

Student4563
This is fine. It's a matter of programming style. I like the way you create new values for each color, calculating the red, copying the green from the newly calculated red, and just cloning the old blue. Nice. Colin Potts

def redREMOVEDOut(myPicture):
  for pixel in getPixels(myPicture):
    avg=(getRed(pixel)+getREMOVED(pixel))/2
    setREMOVED(pixel, avg)
    setRed(pixel, avg)





Link to this Page