Conditionals and Booleans
Copyright (c) 2017 Kathi Fisler
1 Reviewing Conditionals and Booleans
Today’s goal was to do another example of if expressions and booleans. We looked at one problem had everyone sketch a solution, and then looked at three different solutions: one used nested-if expressions, one used a combination of if expressions and booleans, and one used only boolean operations.
Here is the code file with the problem statement and the three solutions we went over.
The discussion of the different solutions is best reviewed by watching the lecture capture.
2 Approaching Larger Problems
The coordinate-checker question on this homework is the most substantial program you’ve written to date. It involves several small checks on the contents of a string which you have to then combine into a single program.
We discussed ways to plan your work on this problem: create a function for each bullet item in the problem description, start with the easy items before moving on to the harder ones, and test the function for each item before you move on.
By breaking the problem into functions, you get an easy way to test that each part is working before you combine them into a whole program.
In general, the strategy of breaking a problem into separate tasks that you capture in separate functions lets you build up a program in stages, rather than thinking about the entire problem at once.