First Summer 2006


Homework Three: Straigh-line Python programs (mostly chapter 2 material from the Python text).
Due date
Friday May 19, 11:59pm
Late policy
Please turn everything on time, late solutions will not be accepted.

Work policy
Working in groups is encouraged but please turn in your own version of the assignment.

Also, please make sure you

with the Computer Science Department's Statement on Academic Integrity before turning in your assignment.

Task
Write programs that solve the following problems:

  1. (Calculating a Car's Autonomy) Given a car's mileage (expressed in miles per gallon) and the amount of fuel in the car's tank (expressed in gallons) write a formula to determine the autonomy of that car in miles. Then use the formula that you wrote to write a program that asks the user for the mileage of a car and the amount of fuel in the car and prints back the autonomy of the car in miles. When finished your program should behave like this (you, of course, need to write a Python program).

  2. (An Investment Problem) Assume that your bank account starts with a certain amount of dollars in it and you never take money out. At the end of each year the amount in your account goes up with 5%. Write a program that asks the user for the initial amount of money in the account, then shows what happens to the account over a period of ten years. What would you have to do to run the analysis over a longer period of, say, 20 years? Here's how your program might behave when you have it done. (You, of course, need to write a Python program).

  3. (Averages) Write a program that asks the user to enter a number per line and prints back (after every line) the current average of all the numbers entered up to that point. Program stops when the user enters done, alone, on the line. Here's how your program might behave when finished. (You, of course, need to write a Python program).

  4. (Parens) Write a program that receives a string and rewrites it with parens around each vowel. Here's how my program works. (You, of course, need to write a Python program).

  5. (Stenographer) Write a program that removes all vowels from a string of characters. Essentially the program asks the user for a line of input, then writes back only the consonants in the line, Here's how your program might look when finished. (You need to write a Python program, of course).

Grading
Feedback will be provided within a week, grades will be posted on-line.