NEW
Font size
WorksheetsUnit 7- Lesson 11: Assessment Day
Total questions: 15
Worksheet time: 8mins
Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment.
num % 2 == 0;
num % 0 == 2;
num % 1 == 0;
num % 1 == 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)?
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);
[2, 5, 3, 1, 6]
[0, 3, 6, -1, 9]
[-1, 2, 6, -2, 8]
[5, 2, 6, 3, 9]
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;
}
}
findMin(-1, 0)
findMin(2,4)
findMin(5,10)
findMin(5,3)
findMin(7,2)
findMin(5,1)
findMin(1,1)
findMin(-2,2)
findMin(0,3)
findMin(-1,1)
findMin(1,-1)
findMin(1,1)
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);
4
0
1
3
listAverage() returns the average number in a list. Which of these functions does this correctly?
What is printed to the console?
console.log(15 % 4);
2
3
4
1
Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems.
procedural abstraction
API
modularity
library
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?
OPTION A
OPTION B
OPTION C
OPTION D
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?
numList[i] = min;
min = numList[i];
min = numList;
numList = min;
Algorithms can be created in all the following ways EXCEPT:
creating from an idea
combining existing algorithms
removing sequencing, selection, and iteration from an algorithm
modifying existing algorithms
Using existing algorithms as building blocks for new algorithms has all the following benefits EXCEPT:
reduces development time
reduces testing
simplifies debugging
removes procedural abstraction
What is one of the benefits of using a library in a program?
simplifies creating a complex program
increases development time
removes all testing
reduces abstractions in the program
Dividing a program into separate subprograms (such as libraries) is known as:
documentation
iteration
modularity
API
Which call of the function correctly follows the instructions laid out in the API?
moveElement("button1", 2, 23);
moveElement("button1", "left", "thirty");
moveElement("button1", 30, "two");
moveElement("button1", "down", 25);
