Lesson 8: Creating Functions with Parameters Day 28 Happy Halloween
Finish Lesson 7 Finish Lesson 7 From Friday
Lesson 8- Objectives Today Write functions with parameters to generalize a solution instead of duplicating code. Identify appropriate situations for creating a function with parameters. Use random numbers as inputs to function calls for the purpose of testing.
Lesson 8- Objectives Today Add parameters to a function in an existing piece of code to generalize its behavior.
Lesson 8 Writing functions with parameters can generalize solutions to problems even further. Especially in situations where feel like you are about to duplicate some code with only a few changes to some numbers, that is a good time to write a function that accepts parameters.
Lesson 8 The basic idea is that you often want to write a function that takes some input and performs some action based on that input For example, the turtle function moveForward is much more useful when you can specify how much to move forward (e.g., moveForward(100)), rather than just a fixed amount every time.
Lesson 8 It’s very common to encounter situations where as a programmer you realize that you basically need a duplicate of some code you’ve already got, but you just want to change some numbers.
Lesson 8 That’s a good time to write a function with a parameter; the parameter just acts as a placeholder for some value that you plug in at the time you call the function. Just like it’s considered good practice to give descriptive names to your functions, the same is true for the names of the parameters themselves.
Lesson 8 Watch the Video: Functions with Parameters – Video
Complete Code.org Lesson 8 Writing Functions with Parameters: Under the Sea
Review / End Day Next Class Quiz on Abstraction Video Lesson 9-