Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

P5js

Total questions: 30

Worksheet time: 18mins

Name
Class
Date
1.

What is the purpose of declaring variables in p5js editor?

a)

To create animations with sound

b)

To change the background color of the webpage

c)

To display images on the canvas

d)

To store and manipulate data within the program.

2.

What is the process of assigning values to variables in p5js?

a)

Using the syntax 'variableName = value;'

b)

Using the syntax 'var variableName = value;'

c)

Using the syntax 'let variableName = value;'

d)

Using the syntax 'const variableName = value;'

3.

What happens if you declare a variable inside a function in p5js?

a)

It becomes a variable with block scope and can only be accessed within the block of code where it is declared.

b)

It becomes a constant and cannot be changed within the function.

c)

It becomes a local variable and can only be accessed within that function.

d)

It becomes a global variable and can be accessed from anywhere in the code.

4.

How can you access a global variable from within a function in p5js?

a)

By creating a new variable with the same name within the function

b)

By using the function name instead of the variable name

c)

By using the variable name within the function

d)

By using the variable name outside of the function

5.

Explain the difference between local and global variables in p5js.

a)

Local variables are declared within a specific function or block of code, while global variables are declared outside of any function.

b)

Local variables are accessible from anywhere in the code, while global variables are only accessible within a specific function.

c)

Local variables have a longer lifespan than global variables.

d)

Local variables are declared using var keyword, while global variables are declared using let keyword.

6.

What function to alter the

colour of the following shapes drawn

a)

stroke

b)

strokeWeight

c)

color

d)

colour

7.

What is the name of the first function that only runs once?

(a)  

8.

What is the name of the second function that runs continually?

(a)  

9.

Type the character that starts the definition of a function

i.e function draw()_

What is the missing character?

(a)  

10.

Type the character that ends the definition of a function

(a)  

11.

What command changes the colour of the background?

(a)  

12.

What command changes the size of area in which p5js can draw?

(a)  

13.

What function would you use to draw a circle

(a)  

14.

What function would you use to draw a rectangle

(a)  

15.

What function would you use to draw a square

(a)  

16.

What function would you use to draw a quadrilateral

(a)  

17.

What function to alter the

width of the stroke used for lines, points and the border around shapes

a)

stroke

b)

strokeWeight

c)

color

d)

colour

18.

What function to alter the

colour of the following shapes drawn

a)

stroke

b)

strokeWeight

c)

color

d)

colour

19.

What system variable stores the position

of the pointer on the X axis

(a)  

20.

What system variable stores the position

of the pointer on the Y axis

(a)  

21.

What system variable stores the

height of the canvas

(a)  

22.

What system variable stores the

width of the canvas

(a)  

23.

What is p5js?

a)

p5js is a JavaScript library for creating interactive graphics and animations in the browser.

b)

p5js is a programming language used for data analysis and visualization.

c)

p5js is a JavaScript framework for building mobile applications.

d)

p5js is a Python library for creating interactive graphics and animations in the browser.

24.

What are the main subtopics of p5js?

a)

variables, loops, conditionals, functions

b)

HTML, CSS, JavaScript, DOM manipulation

c)

drawing, animation, interaction, sound

d)

shapes, colors, text, images

25.

What is the purpose of p5js?

a)

p5js is a JavaScript library for game development.

b)

p5js is a JavaScript library for web design.

c)

p5js is a JavaScript library for creative coding.

d)

p5js is a JavaScript library for data analysis.

26.

How do you create a canvas in p5js?

a)

createCanvas()

b)

canvas.new()

c)

makeCanvas()

d)

canvas.create()

27.

What are the basic shapes that can be drawn in p5js?

a)

point, line, triangle, rectangle, ellipse, and arc

b)

square, circle, polygon

c)

dot, curve, square

d)

line, circle, polygon

28.

How do you draw a rectangle in p5js?

a)

drawRect(x, y, width, height)

b)

createRectangle(x, y, width, height)

c)

makeRect(x, y, width, height)

d)

rect(x, y, width, height)

29.

How do you draw a circle in p5js?

a)

ellipse()

b)

circle()

c)

drawCircle()

d)

createCircle()

30.

How do you change the background color in p5js?

a)

setBackgroundColor(color)

b)

changeBackground(color)

c)

modifyBackground(color)

d)

background(color)