MONT 105S, Spring 2009
Home | | Course Schedule | | Assignments | | Lecture Notes
You will write a program which administers a questionaire, then prints back a few sentences using the information it got from you. The program will be written in the Python language, and it will use variables to keep the information it collects.
Name this program journey.py
Hi there! What is your name? Frodo Baggins Where are you going? Mount Doom How far have you traveled (in miles)? 10 Let me see if I have this straight: Frodo Baggins has traveled 52800 feet on the way to Mount Doom. Thanks for running the program.
In the above example, the underlined items are user input. Note that when you run your python program, the user input will be on the same line as the question requesting the input. The idea is that the person running the program (which might not be you) answers the three questions, and then the computer fits the answers into its sentence. Note that for this example to work, the user has to answer in a particular form. If the user had answered 'to Mount Doom' in response to the second question, the program would print out 'Frodo Baggins has traveled 52800 feet on the way to to Mount Doom.' More advanced programs can check for this kind of thing and correct for it, but you don't have to worry about it for this assignment. Note also that the computer converts the distance from miles to feet. Recall that 1 mile is 5280 feet. Your program should print out the number of feet that corresponds to the number of miles that the user inputs.
Name this program tipComputer.py.
A sample session might look like this:
As with the previous program, when you run your python program, the user input will be on the same line as the question requesting the input. You should not worry about the number of decimal places printed for this particular problem.Please enter the amount of the bill: 15.34 A 15% tip would be $ 2.301 A 20% tip would be $ 3.068
What you will turn in: