< Back

Test #1 Review

Answer the following conceptual question

  1. What is the smallest division of an image referred to as?
For the following problems, write what would be printed by the Python program. If there is an error, write Error, and circle the error.
  1.       for times in range(5):
              print(times)
        
  2.       for character in "INQ241 A":
              print(character)
        
For the following problems, write what would be printed by the Python program. If there is an error, write Error, and circle the error. Assume that any image opened in the following programs is the following image: Assume the top-left pixel is true red, the top-right pixel is true green, the bottom-left pixel is true blue, and the bottom-right pixel is true white.
  1.       picture = makePicture(pickAFile())
          for pixel in picture:
              print(pixel)
        
  2.       picture = makePicture(pickAFile())
          for pixel in picture:
              print(getRed(pixel))
        
  3.       picture = makePicture(pickAFile())
          for pixel in picture:
              print(getGreen(pixel))
        
  4.       picture = makePicture(pickAFile())
          for x in range(getWidth(picture)):
              for y in range(getHeight(picture)):
                  pixel = getPixel(picture, x, y)
                  print(getBlue(pixel)
    
        
  5.       picture = makePicture(pickAFile())
          for pixel in picture:
              setRed(pixel, 0)
    
          for x in range(getWidth(picture)):
              for y in range(getHiehgt(picture)):
                  pixel = getPixel(picture, x, y)
                  print(pixel)
        
  6.       picture = makePicture(pickAFile())
          for pixel in picture:
              redColor = getRed(pixel)
              setRed(pixel, redColor / 2)
    
              greenColor = getGreen(pixel)
              setGreen(pixel, greenColor / 2)
    
              blueColor = getBlue(pixel)
              setBlue(pixel, blueColor / 2)
    
          for x in range(getWidth(picture)):
              for y in range(getHeight(picture)):
                  pixel = getPixel(picture, x, y)
                  print(pixel)
        

For the following Python programs, draw what is drawn to the image.

  1.       picture = makeEmptyPicture(4, 4)
    
          for y in range(getHeight(picture)):
              pixel = getPixel(picture, 1, y)
              setRed(pixel, 255)
        
  2.       picture = makeEmptyPicture(4, 4)
    
          for x in range(getHeight(picture)):
              pixel = getPixel(picture, 1, x)
              setRed(pixel, 255)
        
  3.       picture = makeEmptyPicture(4, 4)
    
          for x in range(getHeight(picture)):
              pixel = getPixel(picture, 1, x)
              setRed(pixel, 255)
              pixel = getPixel(picture, x, 1)
              setRed(pixel, 255)
    
        

For the following problem, write your solution ON PAPER.

  1. Write a Python function negativeRed(a_picture). This function should convert all of the red values of each pixel to be the photonegative value. The photonegative value would be the result of subtracting the current red value from 255.