The Digital World-Lab 5
Assigned: February 18
Due: Thursday, February 26
Note the unusual due date. To get you started with programming
before you leave on Spring break, here are a couple of basic
programming problems.
1. Write a program that converts Centigrade to Fahrenheit
temperatures. Use the Fahrenheit-to-Centigrade program, which is
posted on the main syllabus page. You just have to do a little math (or
look up the formula) to figure out how to invert the process in the
Fahrenheit to Centigrade program. It's a little nicer if you can
avoid outputs like 12.9222222 degrees. So just have the output
appear as an integer. The way you do this in python is with the
function round. For
example, if you type round(7.8)
at the prompt in the command window, you'll get the answer 8.
2. Write a program that opens a picture file with pickAFile,
reduces the blue and green components of every pixel to 70% of their
value, and then saves the resulting picture as a .jpg file. (You
can, to a large extent, imitate the program makeRed.py.You will need to use the writePictureTo function to save the
file. See the online help for this.) Try to find a nice
picture of a seascape to apply this to---you can use your program to
simulate a sunset!
Make sure you include your name as a comment in each of your
programs. Put both your .py files in a folder, and zip it and
submit it in the usual way.