Department of Mathematics, Computer Science, and
                Statistics
St.
                Lawrence University
Zonohedron
 

What is this object?

...

Links
Overview
Schedule
Grading Info
Class Notes

 

CS 140: Introduction to Computer Programming


CLASS CREATION #2
Tuesday, September 18

This afternoon you will create a program called conversion.py that will display a neatly formatted conversion chart on the screen.  Follow the guidelines below as you design and write your program.

  • First choose a quantity that one can measure, such as length, weight, area, monetary value, speed, or anything else you would like. 
  • Then select three different units that could be used to measure this quantity.  The first two should be standard units, while the third should be utterly whimsical.  For instance, for weight you might choose ounces, grams, and Dorito chips.
  • Now do a little online research to find the multiplier that will convert between these units.  Thus I find that 1 ounce = 28.35 grams and 1 ounce = 17.23 chips.
  • With this information securely in hand, write a program that prints out a formatted conversion table with a header row and at least ten rows beneath.  Use tabs to line numbers up in columns, and make the step size for the left-hand column larger than one.  So my chart might start with 10oz, 20oz, 30oz, and so forth.
  • If necessary, use the int command to eliminate the decimal part for a neater table.  If desired, get more fancy by typing int(x+.5) to round a number x to the nearest integer, or type int(10*x)/10.0 to leave one digit past the decimal.

Your output should look something like this.

If you need any guidance do not hesitate to flag down Dr. V or ask a neighbor for help.  Once your program is running satisfactorily, be sure to have Dr. V try it out so that he can give you credit for your creation.