Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

P5.js Test #1 Review

Total questions: 50

Worksheet time: 26mins

Name
Class
Date
1.

Which of the following commands is used to draw a line?

a)

line(x1, y1, x2, y2);

b)

draw the line(x1, y1, x2, y2);

c)

line(x1, y1);

d)

linear(x1, y1, x2, y2);

2.

Which of the following commands is used to draw a rectangle?

a)

rect(x, y, width, height);

b)

rectangle(x, y, width, height);

c)

rect(x1, y1, x2, y2);

d)

rectangle(x1, y1, x2, y2);

3.

Which of the following commands is used to change the colour to draw with?

a)

stroke(0, 100, 0);

b)

changeTheColor();

c)

stroke(x1, y1);

d)

textColor(1, 2, 2);

4.

Which of the following commands is used to change the colour the program fills in solid shapes?

a)

fill(0, 255, 255);

b)

changeBackground();

c)

solid(255, 0, 255);

d)

Color(30, 2, 2);

5.

Which of the following commands is used to draw a square?

a)

square(x, y, width, height);

b)

square(x, y, length);

c)

square(x1, y1, x2, y2, x3, y3, x4, y4);

d)

drawSquare(x1, y1, width);

6.

Which of the following commands is used to draw a circle?

a)

circle(x, y, radius);

b)

circle(x, y, diameter);

c)

circle(x, y);

d)

drawOval(x, y, diameter);

7.

Which of the following commands is used to draw an oval?

a)

ellipse(x, y, width, height);

b)

ellipse(x, y, diameter);

c)

ellipse(x, y);

d)

ellipse(x, y, width, height, depth);

8.

Which of the following commands is used to draw a triangle?

a)

triangle(x1, y1, x2, y2, x3, y3);

b)

triangle(x1, y1, x2, y2, x3, y3, x4, y4);

c)

triangle(x, y, width, height);

d)

triangle(x, y);

9.

Which of the following commands is used to draw a quadrilateral?

a)

quad(x1, y1, x2, y2, x3, y3);

b)

quad(x1, y1, x2, y2, x3, y3, x4, y4);

c)

quad(x, y, width, height);

d)

quad(x, y);

10.

Which of the following commands is used to draw Hello Class on the screen?

a)

text("Hello Class", 50, 20);

b)

text(Hello Class, 50, 20);

c)

draw("Hello Class", 50, 20);

d)

words("Hello Class", 50, 20);

11.

Which of the following commands is used to change the font size of text that is drawn?

a)

textSize(20);

b)

textsize(20);

c)

size(20);

d)

TEXTSIZE(20);

12.

Which of the following commands is used to draw the circle in the image? The canvas size is 200 x 200

a)

circle(25, 25, 20);

b)

circle(175, 25, 20);

c)

circle(175, 175, 20);

d)

circle(25, 175, 20);

13.

Which of the following commands is used to draw the square in the image? The canvas size is 200 x 200

a)

square(175, 10, 20);

b)

square(10, 175, 20);

c)

square(175, 175, 20);

d)

square(100, 100, 20);

14.

Which of the following commands is used to draw the oval in the image? The canvas size is 200 x 200

a)

ellipse(100, 100, 60, 20);

b)

ellipse(100, 100, 60, 60);

c)

ellipse(100, 100, 20, 60);

d)

ellipse(0, 0, 60, 20);

15.

Which of the following commands is used to draw the red triangle in the image? The canvas size is 200 x 200

a)

triangle(0,0, 200,0, 100, 200);

b)

triangle(0,0, 0,200, 100, 200);

c)

triangle(200,0, 0,200, 100, 200);

d)

triangle(200,0, 200,200, 100, 200);

16.
The area where all drawn graphics are displayed is known as the...
a)
console 
b)
canvas
c)
variable
d)
palate
17.
Using RGB, colors range from ___ to ___.
a)
0 - 255
b)
0 - 100
c)
50 - 550
d)
0 - 250
18.

A school has 1200 students. How can you store this information in a JavaScript variable?

a)

let numStudents = 1200

b)

1200 = numStudents

c)

let numStudents 1200

d)

let numStudents == 1200

19.

A student has 5 quarters and 9 dimes in their pocket. How can you store this information in a JavaScript variable?

a)

let quarters = 5

let dimes = 9

b)

let quarters = 9

let dimes = 5

c)

let quarters, dimes = 9

d)

quarters === 5

dimes === 9

20.

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?

a)

let shoes = int(prompt("How many pairs of shoes do you have? "));

b)

let shoes = prompt("How many pairs of shoes do you have? ");

c)

let shoes = int("How many pairs of shoes do you have? ");

d)

int(prompt("How many pairs of shoes do you have? ")); = let shoes

21.

Which of the following lines of code can be used to determine if a number is even?

a)

if (num % 2 == 0)

b)

if (num % 2 = 0)

c)

if (num / 2 == 0)

d)

let itBeEven Now

22.

What would be the result of the following line of code?

print( 33 % 5 )

a)

3

b)

5

c)

6.6

d)

6

23.

In a graphics canvas, what are the coordinates of the top right corner of the window?

a)

( width, 0 )

b)

( width, height )

c)

( 0, height )

d)

( 0, 0 )

24.

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 );

a)

510

b)

105

c)

15

d)

10

25.

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 );

a)

510

b)

105

c)

15

d)

10

26.

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 );

a)

510

b)

105

c)

15

d)

10

27.

Which of the following lines of code will create a constant variable and assign it a value of 1.5 ?

a)

const num1 = 1.5;

b)

num1 = 1.5

c)

const num1;

num1 = 1.5;

d)

constant num1 = 1.5

28.

Which of the following is a valid variable declaration?

a)

let oneApple;

b)

let one Apple;

c)

set oneApple;

d)

let 1Apple;

29.

What will be the output of the following code block?

let num1 = 4
let num2 = "3"
let answer =  num1 + num2
print( answer );

a)

43

b)

7

c)

34

d)

44

30.

Which logical operator symbols are used to represent OR in a Boolean statement?

a)

OR

b)

||

c)

&&

d)

//

31.

Which logical operator symbols are used to represent AND in a Boolean statement?

a)

OR

b)

||

c)

&&

d)

//

32.

Which symbol(s) are used to document a single line of code?

a)

//

b)

??

c)

""

d)

||

33.

Which symbol(s) are used to document a block of code?

a)

/*

*/

b)

/?

?/

c)

/|

|/

d)

/&

&/

34.

The following " an error in the grammar, or form, of a statement. " describes what?

a)

logic error

b)

syntax error

c)

human error

d)

compound if statement

35.

The following "a bug in a program that causes unexpected results or operation but not failure. " describes what?

a)

logic error

b)

syntax error

c)

human error

d)

compound if statement

36.

What datatype would be used to store the city you were born in?

a)

String

b)

Integer

c)

Boolean

d)

Float

37.

What datatype would be used to the number of chairs in the classroom?

a)

String

b)

Integer

c)

Boolean

d)

Float

38.

What datatype would be used to store whether you passed your G2 road test?

a)

String

b)

Integer

c)

Boolean

d)

Float

39.

What datatype would be used to store the average temperature in March?

a)

String

b)

Integer

c)

Boolean

d)

Float

40.

  let num1 = 10
  
  if (num1 <= 10){
    print("Message 1");
  } else {
    print("Message 2")
  }

a)

Message 1

b)

Message 2

c)

Message 1

Message 2

d)

Nothing

41.

  let num1 = 4
  
  if ( num1 == 3 || num1 == 5 ){
    print("Message 1");
  } else {
    print("Message 2");
  }

a)

Message 1

b)

Message 2

c)

Message 1

Message 2

d)

Nothing

42.

  let num1 = 4
  
  if ( num1 == 4 || num1 == 5 ) {
    print("Message 1");
  }
    print("Message 2");

a)

Message 1

b)

Message 2

c)

Message 1

Message 2

d)

Nothing

43.

  let num1 = 5
  
  if ( num1 >= 3 && num1 < 5 ){
    print("Message 1");
  } else {
    print("Message 2");
  }

a)

Message 1

b)

Message 2

c)

Message 1

Message 2

d)

Nothing

44.

  let num1 = 5
  
  if ( num1 >= 3 && num1 <= 5 ) {
    print("Message 1");
  } else {
    print("Message 2");
  }

a)

Message 1

b)

Message 2

c)

Message 1

Message 2

d)

Nothing

45.

let num2 = 10
  
  if ( num2 > 0 ){
    print("Message 1");
  }
  else if (num2 == 2){
    print("Message 2");
  } else { 
    print("Message 3");
  }

a)

Message 1

b)

Message 2

c)

Message 3

d)

Message 1

Message 2

Message 3

46.

let num2 = 5
  
  if ( num2 == 1 ){
    print("Message 1");
  }
  else if (num2 == 2){
    print("Message 2");
  } else { 
    print("Message 3");
  }

a)

Message 1

b)

Message 2

c)

Message 3

d)

Message 1

Message 2

Message 3

47.

The following line of code will generate which of the following numbers?

num1 = int(random(5, 8));

a)

5, 6, 7

b)

5, 6, 7, 8

c)

4, 5, 6, 7

d)

6, 7, 8

48.

Which of the following lines of code will generate a random number in the range 50 to 100 (inclusive) that is a whole number.

a)

let num = int(random(50, 101));

b)

let num = int(random(50, 100));

c)

let num = int(random(49, 101));

d)

let num = random(50, 101);

49.

The following block of code will display which result?

let A = 5

let B = 6

let ans = A * B

print( A + " x " + B + " = " + ans)

a)

5 x 6 = 30

b)

5 x 6 = 56

c)

A x B = ans

d)

A x B = 30

50.

The following block of code will display which result?

let A = 5

let B = 6

let ans = A * B

print( " A x B = " + ans)

a)

5 x 6 = 30

b)

5 x 6 = 56

c)

A x B = ans

d)

A x B = 30