1 of 13

Unit 3 Lesson 8 part 1

Creating Functions with Parameters

2 of 13

To do: December 2

What are three ways express color when calling on �penColor( color ) ? Use the example of cyan.

1.

2.

3.

3 of 13

To do: December 2

What are three ways express color when calling on penColor( color ) ? Use the example of cyan.

  1. penColor("cyan");
  2. penColor(rgb(0,255,255));
  3. penColor("#00FFFF");

4 of 13

Writing Functions with Parameters handout

5 of 13

Complete using pair programming

  • 2019-20 Unit 3 Code.org Lesson 7 Bubbles 2-9
  • 2019-20 Unit 3 Code.org Lesson 8 Bubbles 3-9

6 of 13

Homework

  • Complete in Code.org 2019-20 Unit 3 Lesson 7
    • Bubbles 2-9 in pairs
    • Bubble 10 individually - Use at least 3 different colors - Use moveTo command at least once
  • Khan Academy - Defining a procedure article and 4 questions

7 of 13

function drawHeart(x, y, color, size)

8 of 13

Pair programming Lesson 8: Bubbles 3-7, 10-15

Bubble 6: How do you add a second parameter to a function?

function drawTriangle(size, width)�{

// put pen down and change pen thickness� // draw triangle with size indicated� // put pen up

}

9 of 13

Pair programming Lesson 8: Bubbles 6

function drawTriangle(size, width)�{

penDown();

penWidth(width);

moveForward(size);

turnLeft(120);

moveForward(size);

turnLeft(120);

moveForward(size);

turnLeft(120);

penUp();

}

10 of 13

Pair programming Lesson 8: Bubbles 3-7, 10-15

New command:

randomNumber(min, max) —> returns a number between min and max, inclusive

randomNumber(1,5) —> will return a number 1,2,3,4,or 5

11 of 13

Pair programming Lesson 8: Bubbles 3-7, 10-15

drawFish(randomNumber(10,100),randomNumber(0,255),randomNumber(0,255),randomNumber(0,255));

function drawFish(size, red, green, blue)�{

// function defined

}

12 of 13

Homework

Complete Lesson 8: Bubbles 3-7, 10-15

13 of 13

Homework

Complete U3L08 Writing Functions with Parameters Practice worksheet

DEBUG Code.org Unit 3 Lesson 8 Bubble 15. Make sure two fish, two seagrasses, and two starfish are displayed and there is variability each time you run.

Sea grass should be vertical & limit range of randomNumber(min, max) for fish & starfish.