Unit 3 Lesson 8 part 1
Creating Functions with Parameters
To do: December 2
What are three ways express color when calling on �penColor( color ) ? Use the example of cyan.
1.
2.
3.
To do: December 2
What are three ways express color when calling on penColor( color ) ? Use the example of cyan.
Writing Functions with Parameters handout
Complete using pair programming
Homework
function drawHeart(x, y, color, size)
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
}
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();
}
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
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
}
Homework
Complete Lesson 8: Bubbles 3-7, 10-15
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.