Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment.
function isEven(num){
if(MISSING CONDITION){
return true;
} else {
return false;
}
}
AP CSP Unit 7: Parameters, Returns, and Libraries
Quiz
•
Computers
•
9th - 12th Grade
•
Medium
Erin Torres
Used 1K+ times
FREE Resource
26 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment.
function isEven(num){
if(MISSING CONDITION){
return true;
} else {
return false;
}
}
num % 2 == 0;
num % 0 == 2;
num % 1 == 0;
num % 1 == 2;
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
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 gray square without hitting a wall or a barrier (black square)?
3.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
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]
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
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)
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
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);
1
4
0
3
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
listAverage() returns the average number in a list. Which of these functions does this correctly?
7.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What is printed to the console?
console.log(15 % 4);
2
3
4
1
30 questions
Python
Quiz
•
9th Grade
22 questions
Python Fundamentals
Quiz
•
12th Grade
28 questions
CSP Unit 7 Review Code.org
Quiz
•
9th - 12th Grade
30 questions
Excel Review(formulas, lookups, formattings)
Quiz
•
11th Grade
23 questions
Important Keys
Quiz
•
9th Grade
25 questions
Excel functions and formulas assessment
Quiz
•
9th - 11th Grade
21 questions
CodeHS JavaScript
Quiz
•
8th - 12th Grade
26 questions
P5.js Review - Part 2
Quiz
•
10th Grade
15 questions
Multiplication Facts
Quiz
•
4th Grade
20 questions
Math Review - Grade 6
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions
Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines
Quiz
•
Professional Development
12 questions
Dividing Fractions
Quiz
•
6th Grade
25 questions
Spanish preterite verbs (irregular/changed)
Quiz
•
9th - 10th Grade
10 questions
Identify Slope and y-intercept (from equation)
Quiz
•
8th - 9th Grade
10 questions
Juneteenth: History and Significance
Interactive video
•
7th - 12th Grade
8 questions
"Keeping the City of Venice Afloat" - STAAR Bootcamp, Day 1
Quiz
•
9th - 12th Grade
26 questions
June 19th
Quiz
•
4th - 9th Grade
20 questions
Distance, Midpoint, and Slope
Quiz
•
10th Grade
20 questions
Figurative Language Review
Quiz
•
10th Grade
27 questions
STAAR English 1 Review
Quiz
•
9th Grade