wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Unit 7- Lesson 11: Assessment Day

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment.

a)

num % 2 == 0;

b)

num % 0 == 2;

c)

  num % 1 == 0;

d)

  num % 1 == 2;

2.

Here is the API for a robot library.

// moves the robot forward

function moveForward();

// turns the robot to the left

function rotateLeft();

// turns the robot to the right

function rotateRight();

// checks if a robot can move in any direction

// direction {string} - the direction to be checked

// return {Boolean} - true if the robot can move in that direction, otherwise returns false function canMove(direction);

Which code segment will guarantee that the robot makes it to the grey square without hitting a wall or a barrier (black square)?

a)
b)
c)
d)
3.

What will be printed to the console after this program runs?

var numbers = [2, 5, 3, 1, 6]

function changeNums(numList, addNum, subtractNum){

for(var i=0; i<numList.length; i++){

if(numList[i] % 3 == 0){ numList[i] = numList[i] + addNum;

} else {

numList[i] = numList[i] - subtractNum;

}

}

}

changeNums(numbers, 3, 2);

console.log(numbers);

a)

[2, 5, 3, 1, 6]

b)

[0, 3, 6, -1, 9]

c)

  [-1, 2, 6, -2, 8]

d)

  [5, 2, 6, 3, 9]

4.

Which function calls would provide the most helpful test of this function?

Remember: With tests, you are attempting to figure out all the possible ways the function could be broken.

function findMin(num1, num2){

if(num1 < num2){

return num1;

} else {

return num2;

}

}

a)

findMin(-1, 0)

findMin(2,4)

findMin(5,10)

b)

findMin(5,3)

findMin(7,2)

findMin(5,1)

c)

findMin(1,1)

findMin(-2,2)

findMin(0,3)

d)

findMin(-1,1)

findMin(1,-1)

findMin(1,1)

5.

You have imported a library with the birthMonth() function. Based on the API, how many strings are inputed to calculate the birth month?

// calculate birth month based on the day of the month, day of the week, and the birth year

// dayMonth {number} - a day of a month from 1 to 31

// dayWeek {string} - the name of the day of the week

// year {number} - the birth year

// return {string} - the month you were born

BirthdayLibrary.birthMonth(dayMonth, dayWeek, year);

a)

4

b)

0

c)

1

d)

3

6.

listAverage() returns the average number in a list. Which of these functions does this correctly?

a)
b)
c)
d)
7.

What is printed to the console?

console.log(15 % 4);

a)

2

b)

3

c)

4

d)

1

8.

Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems.

a)

  procedural abstraction

b)

  API

c)

  modularity

d)

library

9.

This function checks if a character is a vowel. If it is, it returns true. Otherwise, it returns false.

Where should return false; be written in the code?

a)

OPTION A

b)

OPTION B

c)

OPTION C

d)

OPTION D

10.

This function finds the minimum number in a list. What should <MISSING CODE SEGMENT> be replaced with in order for this function to operate as expected?

a)

numList[i] = min;

b)

min = numList[i];

c)

min = numList;

d)

numList = min;

11.

Algorithms can be created in all the following ways EXCEPT:

a)

creating from an idea

b)

combining existing algorithms

c)

  removing sequencing, selection, and iteration from an algorithm

d)

modifying existing algorithms

12.

Using existing algorithms as building blocks for new algorithms has all the following benefits EXCEPT:

a)

reduces development time

b)

reduces testing

c)

simplifies debugging

d)

  removes procedural abstraction

13.

What is one of the benefits of using a library in a program?

a)

simplifies creating a complex program

b)

increases development time

c)

removes all testing

d)

reduces abstractions in the program

14.

Dividing a program into separate subprograms (such as libraries) is known as:

a)

  documentation

b)

iteration

c)

modularity

d)

  API

15.

Which call of the function correctly follows the instructions laid out in the API?

a)

moveElement("button1", 2, 23);

b)

moveElement("button1", "left", "thirty");

c)

moveElement("button1", 30, "two");

d)

moveElement("button1", "down", 25);