![]() ![]() |
![]() | Patrice Koehl |
Introduction to Computers: Fall 2013Lab9: Programming with Python (III)This is your third programming assignment!
Obviously, you will still program using Python... Step 1: Getting readyPlease use IDLE as your interface to using Python. Create a file in which you will save your program. To do this using IDLE:
Now you are ready to write your program! Step 2: Generate proper headerIt is always worth documenting your program as much as you can!
In your file, add the following lines at the top: # # Author: Your name # Student ID: Your student ID # Date: Today's date # where obviously, "Your name", "Your student ID" and "Today's date" refer to you and the date you are working on this program! Step 3: ProgrammingYou will now solve two small programming exercises; put your solutions to all problems in the file you are working on, one below the other. Remember to test your program! Problem 1: Find the day of the week corresponding to a date Write a Python program that reads from standard input a date (given with Month, Day, and Year) and compute the corresponding day of the week.Let us suppose that we have read the date as MONTH, DAY, and YEAR. The calculation of the day of the week is based on the Zeller's congruence formula: h = ( q + (13*(m+1))/5 + K + K/4 + J/4 + 5*J) (modulo 7)
Let us suppose that we have read the first date as MONTH1, DAY1, and YEAR1. We convert this date into a universal date, the Julian Day Number (JDN) using the formula: JDN1 = DAY1 + (153*m1+2)/5 + 365*y1 + y1/4 - y1/100 + y1/400 - 32045
Step 4: File submissionOnce you are sure your program is working, submit your file on Smartsite. Please submit your report as a single document (you can name this document as you want, but do keep the .py extension). It is very important to turn in your assignment. If you do not turn in,
you will not get your credit.
Grading:The maximum score you can get is 50. The breakdown is:
You will get credit for a question only if it is properly executed... Do not forget to logout from the lab computers! |
Page last modified 17 December 2015 | http://www.cs.ucdavis.edu/~koehl/ |