Functions are so important that we’re going to continue getting more practice with them. We’ll also discuss the connection between functions and algorithms, the conceptual heart of computer science.
Throughout this lesson we’ll return to bits of code that we previous implemented as snippets and reimplement them as methods. We’ll also use this as a chance to reinforce some important programming patterns that we’ve already been using.
But let’s start with some debugging practice!
Next, let’s revisit the code we wrote for array search, rewrite it is a method, and then test it using some sample inputs.
Our next practice problem has a tricky loop setup. Let’s review that together, and then you can attempt the problem itself.
Now, let’s revisit the code we wrote for array sum, rewrite it is a method, and then test it using some sample inputs.
As a bit of homework preparation support, let’s talk through how to approach this lesson’s homework problem, since it has another interesting loop setup. We’ll also demonstrate how we can modify the values of arrays that are passed to methods. And we’ll provide practice with a variant of the problem that you need to complete for today’s homework.
Need more practice? Head over to the practice page.