def anIfExample(x,y,z):
  if x > y:
     print x
     print y
  elif z > y:
     print z
     print y
  else:
     print 0
#Main function for part 1 of lecture (Chapter 5)
#Writing a spec is an exercise for variations of this
def removeRedEye(pic, startX, startY, endX, endY, replacementColor):
  red = makeColor(255,0,0)
  for x in range(startX,endX):
    for y in range(startY,endY):
        currentPixel = getPixel(pic,x,y)
        if distance(red,getColor(currentPixel)) < 165:
           setColor (currentPixel, replacementColor)
#Main functions for part 2 of lecture (Chapter 8)
#Section 8.4 Sampling Keyboards
def doubleFrequency(source):
  len = getLength(source)/2 + 1
  target = makeEmptySound(len)
  targetIndex = 0
  for sourceIndex in range(0, getLength(source),2):
    sourceValue= getSampleValueAt(source, sourceIndex)
    setSampleValueAt(target,targetIndex, sourceValue)
    targetIndex = targetIndex + 1
  play(target)
  return target
def halveFrequency(source):
  target = makeEmptySound(getLength(source)*2)
  sourceIndex = 0
  for targetIndex in range(0, getLength(target)):
    value = getSampleValueAt(source, int(sourceIndex))
    setSampleValueAt(target, targetIndex, value)
    sourceIndex = sourceIndex + 0.5
  play(target)
  return target

    

