Introduction to Computer Programming Quiz Answers – Networking Funda

Get All Week Introduction to Computer Programming Quiz Answers

Introduction to Computer Programming Week 01 Quiz Answers

Quiz 1: Getting started with P5.js

Q1. JavaScript is a…?

View
programming language

Q2. P5.js is a…?

View
library

Q3. Where is JavaScript predominately used?

View
building web applications and interactive websites

Q4. In programming what is a command?

View
a single programming instruction issued to the computer to do something

Q5. In programming, what is a library?

View
a collection of code written by someone else to speed up our development.

.

Q6. Select all the answers you think are correct.

P5.js has commands for…?

Hint: Use the P5.js reference page to help you.

View
1.loading and playing sound
2.interacting and manipulating the webpages DOM
3.user interaction with the mouse and keyboard
4.text and typography
5.loading a displaying images
6.drawing primitive shapes

Quiz 2: 2D coordinate system

Q1. What is the P5.js command for a new canvas?

View
createCanvas()

Q2. What is a pixel?

View
the smallest addressable point on the canvas or screen

Q3. The coordinates (0,0) represent which corner of the canvas?

View
top left

Q4. The x coordinate represents the number of pixels:

View
across the canvas from left to right

Q5. The y coordinate represents the number of pixels:

View
down the canvas from top to bottom

Q6. In a coordinate pair, such as (400,300), which coordinate is first?

View
the x coordinate

Q7. Which coordinate system is used by the canvas?

View
Cartesian coordinates

Q8.How will the following rectangle be drawn to the canvas?
rect(100, 200, 150, 300);

View
at x coordinate100, a y coordinate 200, with a width of 150 and height of 300

Introduction to Computer Programming Week 02 Quiz Answers

Quiz 1: RGB colours

Q1. What color does the following RGB color value represent?

(255,255,255)

View
White

Q2. In RGB colors if all 3 values are the same what do we know for definite about the color?

View
None of the above.

Q3. What color is represented by the following RGB value?

View
yellow

(255,255,0)

Q4. What color is represented by the following RGB value?

(0,256,256)

View
not a valid color value

Q5. What color is represented by the following RGB value?

(140, 0, 255)

Hint: You might want to use an online color picker to help you.

View
purple

Q6. What RGB value represents the following color?

View
(255,150,0)

Q7. An RGB color value takes 24 bits of computer memory, 8 bits (or one byte) for red green, and blue. How many colors does this mean we can store overall?

View
16777216

Q8. How many possible values are there for one byte of information?

View
256

Quiz 2: setup, draw, and Programme Flow

Q1. When is the setup() function called?

View
at the start of the program execution

Q2. When is the draw() function called?

View
every frame of animation

Q3. Where would you normally call createCanvas()?

View
in the setup() function

Q4. Look at the following code carefully. What do you expect to see drawn to the screen when the application runs?

12345678910111213
function setup()
{
createCanvas(500, 500);
}

function draw()
{

fill(255, 0, 0);
rect(100, 100, 200, 200);
View
a blue square with the red square partially visible underneath which is appearing as a purple colour.

Q5. Look at the following code carefully. What do you expect to see drawn to the screen when the application runs?

function setup()
{
createCanvas(500, 500);
}
function draw()
{
fill(255, 0, 0, 255);
rect(100, 100, 200, 200);
fill(0, 0, 255, 100);
View
a blue square with a smaller red square overlapping its top left corner

Q6. Look at the following code carefully. What do you expect to be drawn to the screen when it runs?

function setup()
{
createCanvas(500, 500);
}function draw()
{
fill(0, 0, 255);
rect(100, 100, 300, 300);
View
a blue square only

Q7. Consider the following code carefully. What is displayed to the screen when the program is run?

function setup()
{
createCanvas(500, 500);
}
function draw()
{
fill(0, 0, 255);
rect(100, 100, 300, 300);
View
a blue square with rounded corners

Hint: imagine the program has been running for a few seconds and base your judgment on draw having been run several times.

Q8. Consider the following code carefully. What is displayed to the screen when the program is run?

function setup()
{
createCanvas(500, 500);
}
function draw()
{
noStroke();
fill(255, 0, 0, 255);
rect(100, 100, 200, 200);
View
a red square only, with no outline

Hint: If there is some code you don’t recognise. Do not forget you can look it up in the p5.js reference.

Quiz 3: ellipse, rectangle, line, triangle, point

Q1. How many arguments does the point() function take?

Hint: Arguments are the numbers in brackets at the end of the function call separated by commas.

View
2

Q2. Which of the following commands draw the line in the picture below? Two of the answers below are correct, select them both.

Hint: Don’t worry about the precise coordinates try and work out the rough direction of the line.

View
line(320, 80, 100, 250);

line(100,320,80,250);

Q3. Which of the following commands drew the shape in the picture below?

View
ellipse(200, 150, 100, 50);

Q4. Which of the following commands turns the shape green?

View
fill(0,255,0)

Q5. Which of the following commands draws a square to the screen?

View
rect(100, 100, 100, 100)

Q6. Do the following two triangle commands draw the same triangle or a different triangle?

12
triangle(100,100,150,50,200,100);
triangle(150,50,200,100,100,100);

View
the same triangle

Q7. The code below draws the triangle as shown in the first image. what is the smallest number of arguments used in the triangle function call do you need to change to draw the triangle in the second image?

123456789
function setup() {
createCanvas(400, 400);
}

function draw() {
background(0);
fill(200,0,0);
triangle(100,100,150,50,200,100);
}
first image:

second image:

Hint: The bases of the triangles are the same.

View
4

Q8. Which of the following shapes can you not draw with a single P5.js command?

View
star

Quiz 4: Using the console and debugging syntax errors

Q1. Where do you find the console?

View
in the browser’s developer settings

Q2. Look at the following error. Where is the error in the code?

View
somewhere else

Q3. What kind of error or error is included in the following code?

123456789
function setup()
{
createCanvas(500, 500);
}

function draw()
{
triangle(100, 100, 150, 100);
}

View
a semantic error

Q4. What kind of error is included in the following code?

123456789
function setup()
{
createcanvas(500, 500);
}

function draw()
{
rect(100, 100, 150, 100);
}

View
syntax error

Q5. What kind of error is included in the following code?

123456789
function setup()
{
createCanvas(500, 500);
}

function draw()
{
rect(100, 100, 150, 100);

View
there are no errors

Introduction to Computer Programming Week 03 Quiz Answers

Quiz 1: Built-in Variables: mouseX, mouseY, and Events

Q1. Which of the following variables represents the mouse’s Y coordinate?

View
mouseY

Q2. Which of the following statements best represents what a variable is?

View
A variable is a placeholder for a value you can use in your code.

Q3. Study the following code carefully. What is visible on the canvas when the program executes?

1234567891011
function setup()
{
createCanvas(500, 500);
}

function draw()
{
fill(0, 0, 220);
rect(100, 100, 300, 300);
background(0, 0, 0);

View
a black background with a blue square in the centre

Q4. What is displayed on the screen when the following code is executed?

12345678910111213
function setup()
{
createCanvas(500, 500);
}

function draw()
{
background(0, 0, 0);
fill(220, 0, 220);
noStroke();

View
a purple square filling the canvas

Q5. What does the following code draw to the screen?

12345678910111213
function setup()
{
createCanvas(500, 500);
}

function draw()
{
background(0, 0, 0);
noStroke();
fill(220, 0, 220);

View
a purple square in the top left corner of the canvas with a black background

Q6. What does the following code draw to the screen?

12345678910111213
function setup()
{
createCanvas(500, 500);
}

function draw()
{
background(0, 0, 0);
noStroke();
fill(220, 0, 220);

View
a purple rectangle that increases and deceases in size as the user moves the mouse in any direction

Q7. What value is stored in mouseX?

View
a number that represents the mouse’s location across the screen

Q8. When is the keyPressed() function called?

View
After a key has been released

Q9. When is the mousePressed() function called?

Hint: You may want to read the p5.js documentation.

View
when the left mouse button has been pressed

Q10. What colour is the ellipse drawn in the following code after the mouse has been pressed and released?

12345678910111213141516
function setup()
{
createCanvas(500, 500);
}

function draw()
{
fill(255, 0, 0);
rect(100, 100, 300, 300);

View
red

Quiz 2: Create your own variables: var, initialising and assigning

Q1. A variable name cannot start with…?

View
an upper case letter

Q2. Which of the following variables are valid names? (Three are correct.)

View

Q3. Formally, creating a variable is called?

View declaring

Q4. Formally, assigning a variable its first value is called?

View
initialising

Q5. What does a equal at the end of executing the following code?

1234
var a = 3;
var b = 23;
var c = b;
a = c;

View
23

Q6. What does the variable ‘a’ equal at the end of the setup() function in the code snippet below?

1234567
var a = 0;

function setup()
{
createCanvas(400, 200);
a = width;
}

View
400

Q7. What does the variable ‘a’ equal at the end of the setup() function in the code snippet below?

1234567
var a = 0;

function setup()
{
createCanvas(400, 200);
a(height);
}

View
The code contains an error.

Q8. True or False: JavaScript variables can be created without the var keyword?

View
True

Quiz 3: Working with operators

Q1. What does the variable equal at the end of this code snippet?

Try and complete these questions without using a calculator!

1
var a = 10+15;

View
25

Q2. What does the variable equal at the end of this code snippet?

Try and complete these questions without using a calculator!

1
var a = 18/3;

View
6

Q3. What does the variable a equal at the end of this code snippet?

Try and complete these questions without using a calculator!

1
var a = 1010+13;

View
1023

Q4. What does the variable a equal at the end of this code snippet?

Try and complete these questions without using a calculator!

1
var a = 10+100/(5+5);

View
22.5

Q5. What does the variable equal at the end of this code snippet?

Try and complete these questions without using a calculator!

12
var b = 20;
var a = b*20+20/5;

View
160

Q6. What does the variable equal at the end of this code snippet?

Try and complete these questions without using a calculator!

12
var b = -20;
var a = 20-b;

View
40

Q7. What does the variable equal at the end of this code snippet?

Try and complete these questions without using a calculator!

12
var a = 3;
a = a+5*2

View
13

Q8. Look at the following code carefully. How is the ellipse animated across the canvas?

123456789101112131415
var a = 0;

function setup()
{
createCanvas(500, 500);
}

function draw()
{
background(200);

View
Moves the ellipse horizontally

Quiz 4: Inspecting Variables in the Console

Q1. Which 2 of the following commands will write text to the console? (The others will cause an error.)

View
console.log(“hello console”);

console.log(‘hello console’);

Q2. What arithmetic operator replaces ??? in the following console.log() command to correctly display the message in the console?

12
var x = 42;
console.log(“the value of x is ” ??? x);

View
+


1 point

Q3. What is printed to the console during the execution of the following program?

12345678910111213141516
var a = 0;

function setup()
{
createCanvas(500, 500);
}

function draw()
{
background(200);

View
0

Q4. What is printed to the console after executing the following code snippet?

12
var x = 42;
console.log(y);

View
An error occurs

Get All Course Quiz Answers of IBM Technical Support Professional Certificate

Introduction to Hardware and Operating Systems Quiz Answers

Introduction to Software, Programming, and Databases Quiz Answers

Introduction to Networking and Storage Quiz Answers

Introduction to Cybersecurity Essentials Quiz Answers

Introduction to Cloud Computing Coursera Quiz Answers

Introduction to Technical Support Coursera Quiz Answers

Team Networking Funda
Team Networking Funda

We are Team Networking Funda, a group of passionate authors and networking enthusiasts committed to sharing our expertise and experiences in networking and team building. With backgrounds in Data Science, Information Technology, Health, and Business Marketing, we bring diverse perspectives and insights to help you navigate the challenges and opportunities of professional networking and teamwork.

Leave a Reply

Your email address will not be published. Required fields are marked *