Chapter 4Calculate the Day

Image

You now know how to use variables, functions, and libraries. Next up is one of the most important coding tools you’ll need: teaching the computer how to make decisions.

Working with Dates

As you have seen, Python processes your code line by line, one line at a time. It starts at the top of a program, and for every line that isn’t a comment, it does whatever you have told it to do.

And that’s rather boring. If every program written were executed line by line, then every program would do the exact same thing each time it was run. Imagine a website that showed the same content in the same order every single time you ...

Get Captain Code: Unleash Your Coding Superpower with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.