*NOTICE Code Snippets cannot be seen on WordPress Reader, must be viewed on original site ammccann.com
Went for a leap! Practiced a bit more formatting design with this one. Division and modulo spectacular. Now there are a few mistakes as I look back on this one. Some redundant or unnecessary code, but it still worked!
What I found interesting about this one was really getting a handle on the modulo operator and it getting the remainder of a division problem and using it as a Boolean.
Speaking of modulo fun, Easter has an equation that was pretty tricky to get my head around.
Now there were a few exceptions we had to account for with this specific problem, the exception years of ’54, ’81, ’49’, and ’76 which apparently factor a week late on the Easter date.
Now the ultimo calculator type we were to build in a homework exercise was this thing called Zeller’s Congruence, which is an algorithm developed to calculate the day of the week. The formula for this is:
Taking into account:
This had to be put into code which I translated into the following:
This one really helped get your head around some more complex equations for algorithms using the Python syntax.
Programming is much more useful than creating a bunch of calculators, but I think getting your head around things like binary, algorithms, and learning how computers compute is invaluable to learning logic.
Two last calculators, we had to build were a distance converter and a converter that would convert some days into weeks and days.
Keeping the output basic, we are just focused on getting down the syntax.