WorksheetsP5js
Total questions: 30
Worksheet time: 18mins
What is the purpose of declaring variables in p5js editor?
To create animations with sound
To change the background color of the webpage
To display images on the canvas
To store and manipulate data within the program.
What is the process of assigning values to variables in p5js?
Using the syntax 'variableName = value;'
Using the syntax 'var variableName = value;'
Using the syntax 'let variableName = value;'
Using the syntax 'const variableName = value;'
What happens if you declare a variable inside a function in p5js?
It becomes a variable with block scope and can only be accessed within the block of code where it is declared.
It becomes a constant and cannot be changed within the function.
It becomes a local variable and can only be accessed within that function.
It becomes a global variable and can be accessed from anywhere in the code.
How can you access a global variable from within a function in p5js?
By creating a new variable with the same name within the function
By using the function name instead of the variable name
By using the variable name within the function
By using the variable name outside of the function
Explain the difference between local and global variables in p5js.
Local variables are declared within a specific function or block of code, while global variables are declared outside of any function.
Local variables are accessible from anywhere in the code, while global variables are only accessible within a specific function.
Local variables have a longer lifespan than global variables.
Local variables are declared using var keyword, while global variables are declared using let keyword.
What function to alter the
colour of the following shapes drawn
stroke
strokeWeight
color
colour
What is the name of the first function that only runs once?
(a)
What is the name of the second function that runs continually?
(a)
Type the character that starts the definition of a function
i.e function draw()_
What is the missing character?
(a)
Type the character that ends the definition of a function
(a)
What command changes the colour of the background?
(a)
What command changes the size of area in which p5js can draw?
(a)
What function would you use to draw a circle
(a)
What function would you use to draw a rectangle
(a)
What function would you use to draw a square
(a)
What function would you use to draw a quadrilateral
(a)
What function to alter the
width of the stroke used for lines, points and the border around shapes
stroke
strokeWeight
color
colour
What function to alter the
colour of the following shapes drawn
stroke
strokeWeight
color
colour
What system variable stores the position
of the pointer on the X axis
(a)
What system variable stores the position
of the pointer on the Y axis
(a)
What system variable stores the
height of the canvas
(a)
What system variable stores the
width of the canvas
(a)
What is p5js?
p5js is a JavaScript library for creating interactive graphics and animations in the browser.
p5js is a programming language used for data analysis and visualization.
p5js is a JavaScript framework for building mobile applications.
p5js is a Python library for creating interactive graphics and animations in the browser.
What are the main subtopics of p5js?
variables, loops, conditionals, functions
HTML, CSS, JavaScript, DOM manipulation
drawing, animation, interaction, sound
shapes, colors, text, images
What is the purpose of p5js?
p5js is a JavaScript library for game development.
p5js is a JavaScript library for web design.
p5js is a JavaScript library for creative coding.
p5js is a JavaScript library for data analysis.
How do you create a canvas in p5js?
createCanvas()
canvas.new()
makeCanvas()
canvas.create()
What are the basic shapes that can be drawn in p5js?
point, line, triangle, rectangle, ellipse, and arc
square, circle, polygon
dot, curve, square
line, circle, polygon
How do you draw a rectangle in p5js?
drawRect(x, y, width, height)
createRectangle(x, y, width, height)
makeRect(x, y, width, height)
rect(x, y, width, height)
How do you draw a circle in p5js?
ellipse()
circle()
drawCircle()
createCircle()
How do you change the background color in p5js?
setBackgroundColor(color)
changeBackground(color)
modifyBackground(color)
background(color)
