Unit 3 Lesson 8 part 2
Creating Functions with Parameters
To do: December 2
Log into your Code.org account.
Open the 2019-20 Unit 3 Lesson 7 bubble 10 - be ready to share.
To do: December 2
In the following procedure, the parameter str is a string and the parameter num is a number.
PROCEDURE printArgs(str, num)
{
DISPLAY(num)
DISPLAY(str)
DISPLAY(num)
}
Consider the following code segment.
printArgs("**", 1)
printArgs("*", 2)
What is displayed as a result of executing the code segment?
a) 1 * 1 2 ** 2
b) 1 ** 1 2 * 2
c) * 1 * ** 2 **
d) ** 1 ** * 2 *
To do: December 3
In the following procedure, the parameter str is a string and the parameter num is a number.
PROCEDURE printArgs(str, num)
{
DISPLAY(num)
DISPLAY(str)
DISPLAY(num)
}
Consider the following code segment.
printArgs("**", 1)
printArgs("*", 2)
What is displayed as a result of executing the code segment?
a) 1 * 1 2 ** 2
b) 1 ** 1 2 * 2
c) * 1 * ** 2 **
d) ** 1 ** * 2 *
DISPLAY command
Homework
function drawHeart(x, y, color, size)
Complete using pair programming
randomNumber(min, max) —> returns a number between min and max, inclusive
drawFish(randomNumber(10,100),randomNumber(0,255),randomNumber(0,255),randomNumber(0,255));
function drawFish(size, red, green, blue)�{
// function defined
}
Homework