CPSC120
Fundamentals of Computer Science

In-class Activity 28

  1. Create a Python program that prompts the user to enter a color as three numbers between 0 and 1 that represent the red, green, and blue channels of the color. The program should write an ppm image that is entirely the input color.

  2. Create a Python program that creates writes a ppm file that contains a linear gradient. To produce the linear gradient all pixels on a row of the image should be the same color. However, each row should be a different color. The color of a row should be determined by how far it is from the top row such that the color slowly transitions from one color at the top of the image to another color at the bottom.

  3. Create a Python program that prompts the user to enter two colors by specifying the rgb values of the colors as numbers between 0 and 1. The program should write a ppm file that contains a linear gradient with the first color at the top of the image and the second color at the bottom of the image. l.