Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson 8: Creating Functions with Parameters

Similar presentations


Presentation on theme: "Lesson 8: Creating Functions with Parameters"— Presentation transcript:

1 Lesson 8: Creating Functions with Parameters
Day 28 Happy Halloween

2 Finish Lesson 7 Finish Lesson 7 From Friday

3 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.

4 Lesson 8- Objectives Today
Add parameters to a function in an existing piece of code to generalize its behavior.

5 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.

6 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.

7 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.

8 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.

9 Lesson 8 Watch the Video: Functions with Parameters – Video

10 Complete Code.org Lesson 8
Writing Functions with Parameters: Under the Sea

11 Review / End Day Next Class Quiz on Abstraction Video Lesson 9-


Download ppt "Lesson 8: Creating Functions with Parameters"

Similar presentations


Ads by Google