CS199 Computer Science for Beginners  -  Spring 2009

Exercise 5    Due: Thursday, May 14, 2009 at Midnight

See below for instructions about which Python programs you need to send me by e-mail.

Be sure to name your files: Smith-2.py (if your last name was Smith and you were submitting exercise 2).  Etc.

Be sure to put comments in your program at the beginning that include your name, the Programming Exercise number, and a brief description of what your program does.  Put comments throughout your program to indicate what is happening.  Use informative names for your variables and your functions.

Be sure that your program responds appropriately for the full range of inputs.  (For example, if your program is not designed to accept negative numbers, check and make sure that the numbers you receive are NOT negative and print out an appropriate error message.)

Remember: my e-mail address is lmd with the “at” symbol followed by cs.pdx.edu.

99999

Do the following exercises in class on Thursday, May 7, 2009:

Ch. 7 Discussion question 2

Ch. 8, Discussion question 2, parts a, b, e

Ch. 8 Discussion question 3

Chapter 7, Programming Problem 6

Programming assignment: please turn these programs in:

Ch. 8 Programming Problem 3 but I would like for your program to accept two inputs: the initial investment (an integer or floating point number that is greater than zero) and an interest rate (a floating point number greater than 0.00 and less than 1.00).  Make sure you test for valid input.

As an example of valid inputs for this program, if you wanted to find out how many years it would take for a $1000 investment to double with an annual interest rate of 5%, then you should enter 1000 and .05 for the inputs.  Use a print format template so that your output looks like this:

Your investment of  $100.00  will be worth $207.89  in 15 years, using an interest rate of .05

If  you want one extra point, your output should look like this:

Your investment of  $100.00  will be worth $207.89  in 15 years, using an interest rate of 5%

Ch. 8 Programming Problem 11.  Have the user enter one daily temperature at a time, and then just hit “enter” to indicate that there are no more daily temperatures.  Note that each temperature should be an integer or floating point number between -50 and 110; your program should check to see if any of the entries are incorrect, print an appropriate error message, and end the program.