Homework 1
Due: Tuesday, Feb. 7 at 11:59pm on Moodle
Credit: based on materials from Joe O'Rourke and Dominique Thiebaut.
For federal taxes, use the formula: (salary - deductions) x 28%
For state taxes, use the formula: (salary - deductions) x 5%
(These are approximate for some tax brackets.) Add the federal and state taxes together to obtain the total amount of tax the user has to pay. An example of this program running is shown below:
Try to make the output match exactly, then try out a few different names, salaries, and deductions (you will submit these tests are part of your transcript).
Now create a new file and save it as hw1B.py (again including the assignment name and your name at the top). In this program you will ask the user for their speed in miles per hour. Then you will convert several distances in kilometers to miles, using a for loop. After that, using the distance in miles and the speed in miles/hour, compute the time it will take (in hours) to cover this distance. An example is shown below:
Again try to match this output exactly. In your program, make sure to think about variable names, comments, and automation. Your program should use a for loop, not print out each computation individually. You will be evaluated not only on correctness, but readability and Python style.
Finally, create a transcript that demonstrates your code working. From the shell, highlight all the testing you have done and all the output and copy it into a plain text file (.txt extension). On Windows you can use the program Notepad (under Accessories) and on Mac you can use the program TextEdit (under Applications). Save this file as hw1_transcript.txt.
TO SUBMIT ON MOODLE: