Session03 homework for 1 and 2

The `if` and `elif` blocks are very similar. It's worth considering writing a helper function that can be used in both places.