| Item | |
|---|---|
| Released | Week 2 |
| Due | See the course schedule |
| Progress |
Computers can predict the future, at least as far as the day of the week is concerned. The Doomsday Algorithm is a trick for calculating which weekday any date falls on. By the end of this lab you will have a program that does it, and you will be able to do a rough version in your head.
This lab addresses the following course learning outcomes:
CLO 1. Apply Python programming fundamentals to execute and explain computer code that implements interactive, novel solutions to a variety of computable problems.
CLO 2. Implement code consistent with industry-standard practices using professional-grade integrated development environments (IDEs), command-line tools, and version control systems.
Specifically, by the end of this lab you should be able to:
- store a value in a variable and explain what type it holds
- convert a string to an integer with
int(), and say why that conversion is necessary - split one string into several pieces with
.split() - use
+,-,*,//, and%to build a multi-step calculation - call a function that somebody else wrote, passing it the arguments it expects
- print a formatted result with an f-string
Given a date, report its day of the week. The formula needs four things:
- a set of anchor days, one per month, that all fall on the same weekday within a year
- the century and the two-digit year pulled out of the full year
- the offset between the day you were asked about and that month's anchor day
- the remainder after dividing by
7, because a week has seven days
| Month | Anchor | Month | Anchor |
|---|---|---|---|
| January | 3 (4 in a leap year) | July | 11 |
| February | 28 (29 in a leap year) | August | 8 |
| March | 0 | September | 5 |
| April | 4 | October | 10 |
| May | 9 | November | 7 |
| June | 6 | December | 12 |
You do not have to build this table. It is already written for you in src/DayFunctions.py,
as a function you call. It takes a month and a full year, and hands back a number:
anchor_day = get_anchor_day(1, 2026) # anchor_day is now 3A second provided function takes a number from 0 to 6 and hands back a weekday name:
weekday = get_day_of_week(3) # weekday is now "Wednesday"Both are already imported for you at the top of src/main.py, so you can call them the same
way you call int() or print().
Work in pieces rather than one long line:
part_one = 5 * ((century % 4) + (decade % 4) - 1)
part_two = 10 * decade
sum_of_parts = part_one + part_two
day_offset = day - get_anchor_day(month, full_year)
total_offset = sum_of_parts + day_offset
weekday = total_offset % 7
For the year 2026, the century is 20, the decade is 26, and the full year is
2026.
Important
Separating 2026 into 20 and 26 is the one part of this that is genuinely up to you.
Integer division (//) is the tool.
1-23-2026: Friday
The date is echoed exactly as the user typed it, then a colon, then the weekday.
Open src/main.py and work through the TODO markers top to bottom. Run it as you go:
uv run python src/main.py
Important
Run every command in this README from the assignment's working directory, which is the
top-level folder you land in right after cloning, for example .../lab01-doomsday-algorithm.
Notice that the command above says src/main.py: you stay at the top level and point into
src, rather than using cd to move inside it.
Run pwd if you are not sure where you are. Two signs you are in the wrong directory:
can't open file ... src/src/main.pymeans you already moved intosrcThe path gatorgrade.yml either does not exist or is not validmeans the checks below cannot find their configuration
This lab is worth 4.5 points, which is the standard value for a lab in this course.
| Component | Points | What it measures |
|---|---|---|
| Programming | 3.0 | The 8 code checks below. Your score is the fraction passed, times 3.0 |
| Code quality and style | 1.0 | Descriptive names (0.3), clear organization (0.3), useful comments (0.4) |
| Summary writing | 0.5 | A complete, thoughtful docs/summary.md |
| Total | 4.5 |
Run the checks yourself, as many times as you like, before you submit. This one also runs from
the working directory, not from inside src:
uv run gatorgrade --config gatorgrade.yml
Eight of the checks are about your code:
- the program runs and prints a result
- it reports the correct weekday for a set of dates, including a November date and a leap day
- no
TODOmarkers remain insrc/main.py - the program contains at least 5 comments
- it uses
.split()andint()
Partial credit is proportional: passing 6 of 8 checks earns (6 ÷ 8) × 3.0 = 2.25 points.
The remaining two checks look at docs/summary.md. They confirm the document is finished, and
they count toward Summary writing below rather than toward these 3.0 points.
Note
Automated results are preliminary. Your instructor sets the final grade.
Graded by a human reading your code. Descriptive variable names, sensible organization, and comments that explain why rather than restating what the line already says. A comment that misdescribes its code counts against you.
Complete docs/summary.md. Every question answered fully. Minimum word
count is 150.
Two of the checks single out November and leap days. That is deliberate. A version of this algorithm can be wrong for exactly one month, or only in leap years, and still look perfectly correct on every date you happen to try. Choose your test cases to attack your code, not to flatter it.
A Technical Leader or the instructor will conduct a code review with you on this lab. Code reviews are graded separately from the 4.5 points above, under the Code Reviews category on the syllabus.
Two things happen, with you present:
- You run your program for the reviewer, on a date they may choose
- You answer questions about your own code, including the concepts behind it
The reviewer opens a Code Review issue on your repository and fills it out during the conversation. Come prepared to explain:
- how you separated the century and decade out of the full year
- how the anchor day and the day offset combine to produce the final weekday
- a demonstration date, traced through the calculation, including why the result is taken
mod 7
Your review must be completed during the lab session on the day this lab is due. If you cannot attend that lab and complete your review then, make arrangements to complete it beforehand at office hours:
- Technical Leaders, listed on the calendar at cis.allegheny.edu/community/news
- Dr. Jumadinova, book a time. Drop-ins are welcome during posted hours, but students who booked are seen first
Commit and push often. The last version pushed before the deadline is the one that gets graded. If you need more time, apply a late token with this form.
In the terminal:
git add src/main.py docs/summary.md
git commit -m "Complete the Doomsday Algorithm"
git push
In VS Code, the Source Control panel in the left sidebar does the same three steps:
- Click + next to a changed file to stage it (this is
git add) - Type a message in the box at the top, then click the checkmark (this is
git commit) - Click Sync Changes (or the ↑ arrow) to push
Either way, then open your repository on GitHub and confirm your latest changes are actually there.