WorksheetsP5.js Test #1 Review
Total questions: 50
Worksheet time: 26mins
Which of the following commands is used to draw a line?
line(x1, y1, x2, y2);
draw the line(x1, y1, x2, y2);
line(x1, y1);
linear(x1, y1, x2, y2);
Which of the following commands is used to draw a rectangle?
rect(x, y, width, height);
rectangle(x, y, width, height);
rect(x1, y1, x2, y2);
rectangle(x1, y1, x2, y2);
Which of the following commands is used to change the colour to draw with?
stroke(0, 100, 0);
changeTheColor();
stroke(x1, y1);
textColor(1, 2, 2);
Which of the following commands is used to change the colour the program fills in solid shapes?
fill(0, 255, 255);
changeBackground();
solid(255, 0, 255);
Color(30, 2, 2);
Which of the following commands is used to draw a square?
square(x, y, width, height);
square(x, y, length);
square(x1, y1, x2, y2, x3, y3, x4, y4);
drawSquare(x1, y1, width);
Which of the following commands is used to draw a circle?
circle(x, y, radius);
circle(x, y, diameter);
circle(x, y);
drawOval(x, y, diameter);
Which of the following commands is used to draw an oval?
ellipse(x, y, width, height);
ellipse(x, y, diameter);
ellipse(x, y);
ellipse(x, y, width, height, depth);
Which of the following commands is used to draw a triangle?
triangle(x1, y1, x2, y2, x3, y3);
triangle(x1, y1, x2, y2, x3, y3, x4, y4);
triangle(x, y, width, height);
triangle(x, y);
Which of the following commands is used to draw a quadrilateral?
quad(x1, y1, x2, y2, x3, y3);
quad(x1, y1, x2, y2, x3, y3, x4, y4);
quad(x, y, width, height);
quad(x, y);
Which of the following commands is used to draw Hello Class on the screen?
text("Hello Class", 50, 20);
text(Hello Class, 50, 20);
draw("Hello Class", 50, 20);
words("Hello Class", 50, 20);
Which of the following commands is used to change the font size of text that is drawn?
textSize(20);
textsize(20);
size(20);
TEXTSIZE(20);
Which of the following commands is used to draw the circle in the image? The canvas size is 200 x 200
circle(25, 25, 20);
circle(175, 25, 20);
circle(175, 175, 20);
circle(25, 175, 20);
Which of the following commands is used to draw the square in the image? The canvas size is 200 x 200
square(175, 10, 20);
square(10, 175, 20);
square(175, 175, 20);
square(100, 100, 20);
Which of the following commands is used to draw the oval in the image? The canvas size is 200 x 200
ellipse(100, 100, 60, 20);
ellipse(100, 100, 60, 60);
ellipse(100, 100, 20, 60);
ellipse(0, 0, 60, 20);
Which of the following commands is used to draw the red triangle in the image? The canvas size is 200 x 200
triangle(0,0, 200,0, 100, 200);
triangle(0,0, 0,200, 100, 200);
triangle(200,0, 0,200, 100, 200);
triangle(200,0, 200,200, 100, 200);
A school has 1200 students. How can you store this information in a JavaScript variable?
let numStudents = 1200
1200 = numStudents
let numStudents 1200
let numStudents == 1200
A student has 5 quarters and 9 dimes in their pocket. How can you store this information in a JavaScript variable?
let quarters = 5
let dimes = 9
let quarters = 9
let dimes = 5
let quarters, dimes = 9
quarters === 5
dimes === 9
You want to read input from the user to know how many pairs of shoes they have. Which statement should you use to read in a number from the user?
let shoes = int(prompt("How many pairs of shoes do you have? "));
let shoes = prompt("How many pairs of shoes do you have? ");
let shoes = int("How many pairs of shoes do you have? ");
int(prompt("How many pairs of shoes do you have? ")); = let shoes
Which of the following lines of code can be used to determine if a number is even?
if (num % 2 == 0)
if (num % 2 = 0)
if (num / 2 == 0)
let itBeEven Now
What would be the result of the following line of code?
print( 33 % 5 )
3
5
6.6
6
In a graphics canvas, what are the coordinates of the top right corner of the window?
( width, 0 )
( width, height )
( 0, height )
( 0, 0 )
What is the output of the following program: (Assume the user enters ‘10’ then ‘5’.)
let num1 = prompt("What is your first number? ");
let num2 = prompt("What is your second number? ");
let answer = num2 + num1;
print ( answer );
510
105
15
10
What is the output of the following program: (Assume the user enters ‘10’ then ‘5’.)
let num1 = int(prompt("What is your first number? "));
let num2 = int(prompt("What is your second number? "));
let answer = num1 + num2;
print ( answer );
510
105
15
10
What is the output of the following program: (Assume the user enters ‘10’ then ‘5’.)
let num1 = int(prompt("What is your first number? "));
let num2 = int(prompt("What is your second number? "));
let answer = num2+ num2;
print ( answer );
510
105
15
10
Which of the following lines of code will create a constant variable and assign it a value of 1.5 ?
const num1 = 1.5;
num1 = 1.5
const num1;
num1 = 1.5;
constant num1 = 1.5
Which of the following is a valid variable declaration?
let oneApple;
let one Apple;
set oneApple;
let 1Apple;
What will be the output of the following code block?
let num1 = 4
let num2 = "3"
let answer = num1 + num2
print( answer );
43
7
34
44
Which logical operator symbols are used to represent OR in a Boolean statement?
OR
||
&&
//
Which logical operator symbols are used to represent AND in a Boolean statement?
OR
||
&&
//
Which symbol(s) are used to document a single line of code?
//
??
""
||
Which symbol(s) are used to document a block of code?
/*
*/
/?
?/
/|
|/
/&
&/
The following " an error in the grammar, or form, of a statement. " describes what?
logic error
syntax error
human error
compound if statement
The following "a bug in a program that causes unexpected results or operation but not failure. " describes what?
logic error
syntax error
human error
compound if statement
What datatype would be used to store the city you were born in?
String
Integer
Boolean
Float
What datatype would be used to the number of chairs in the classroom?
String
Integer
Boolean
Float
What datatype would be used to store whether you passed your G2 road test?
String
Integer
Boolean
Float
What datatype would be used to store the average temperature in March?
String
Integer
Boolean
Float
let num1 = 10
if (num1 <= 10){
print("Message 1");
} else {
print("Message 2")
}
Message 1
Message 2
Message 1
Message 2
Nothing
let num1 = 4
if ( num1 == 3 || num1 == 5 ){
print("Message 1");
} else {
print("Message 2");
}
Message 1
Message 2
Message 1
Message 2
Nothing
let num1 = 4
if ( num1 == 4 || num1 == 5 ) {
print("Message 1");
}
print("Message 2");
Message 1
Message 2
Message 1
Message 2
Nothing
let num1 = 5
if ( num1 >= 3 && num1 < 5 ){
print("Message 1");
} else {
print("Message 2");
}
Message 1
Message 2
Message 1
Message 2
Nothing
let num1 = 5
if ( num1 >= 3 && num1 <= 5 ) {
print("Message 1");
} else {
print("Message 2");
}
Message 1
Message 2
Message 1
Message 2
Nothing
let num2 = 10
if ( num2 > 0 ){
print("Message 1");
}
else if (num2 == 2){
print("Message 2");
} else {
print("Message 3");
}
Message 1
Message 2
Message 3
Message 1
Message 2
Message 3
let num2 = 5
if ( num2 == 1 ){
print("Message 1");
}
else if (num2 == 2){
print("Message 2");
} else {
print("Message 3");
}
Message 1
Message 2
Message 3
Message 1
Message 2
Message 3
The following line of code will generate which of the following numbers?
num1 = int(random(5, 8));
5, 6, 7
5, 6, 7, 8
4, 5, 6, 7
6, 7, 8
Which of the following lines of code will generate a random number in the range 50 to 100 (inclusive) that is a whole number.
let num = int(random(50, 101));
let num = int(random(50, 100));
let num = int(random(49, 101));
let num = random(50, 101);
The following block of code will display which result?
let A = 5
let B = 6
let ans = A * B
print( A + " x " + B + " = " + ans)
5 x 6 = 30
5 x 6 = 56
A x B = ans
A x B = 30
The following block of code will display which result?
let A = 5
let B = 6
let ans = A * B
print( " A x B = " + ans)
5 x 6 = 30
5 x 6 = 56
A x B = ans
A x B = 30
