0% found this document useful (0 votes)
105 views

CSP Unit 7 Parameters, Return, and Libraries Assessment Flashcards Quizlet

Uploaded by

w5jm6wr6hj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views

CSP Unit 7 Parameters, Return, and Libraries Assessment Flashcards Quizlet

Uploaded by

w5jm6wr6hj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Find it faster with a search Log in Sign up

Science Computer Science

CSP Unit 7 Parameters,


Return, and Libraries
Assessment
4.3 (27 reviews)

Tap the card to flip

}
return false;
} else {
return true;
if(MISSING CONDITION){
function isEven(num){ num % 2 == 0;
CONDITION" with the correct code segment.
returned if a number is even? Replace "MISSING
Which code segment results in "true" being

Tap the card to flip

1 / 15

Flashcards Learn

Test Match

Q-Chat

sofiaelise_ Share
Created 2 years ago

Students also viewed

CSP Unit 10 Cybersecurity and Glob… Unit 7 Assessment

20 terms 15 terms

NotMrEllis Preview parker23527

Terms in this set (15)

Which code num % 2 == 0;


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;
}
}

Here is the API for function solveMaze(){


a robot library. moveForward();
moveForward();
// moves the robot rotateRight();
forward while(canMove("forward")){
function moveForward();
moveForward(); }
rotateLeft();
// turns the robot moveForward();
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)?

What will be printed to


[0, 3, 6, -1, 9]
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);

Which findMin(-1, 1)
function calls findMin(1, -1)
would findMin(1, 1)
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;
}
}

You have imported a1library 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);

listAverage() function listAverage(list) {


returns the var sum = 0;
average for (var i = 0; i < list.length; i++) {
number in a sum = sum + list[i];
list. Which of }
these return sum / list.length;
functions }
does this
correctly?

What is 3
printed to the
console?
console.log(15
% 4);

Which of the Procedural abstraction


following is improves the speed at which a
not true program executes.
about
procedural
abstraction?

This function checks ifOPTION C


a character is a vowel.
If it is, it returns true.
Otherwise, it returns
false.
Where should return
false; be written in the
code?

function
checkVowel(character)
{
var vowels = ["a", "e", "i",
"o", "u"];
for(var i=0;
i<vowels.length; i++){
if(vowels[i] ==
character){
return true;
OPTION A
}
OPTION B
}
OPTION C
}
OPTION D

This function min = numList[i];


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

function
min(numList){
var min =
numList[0];
for(var i=0;
i<numList.length;
i++){
if(numList[i] <
min){
<MISSING
CODE
SEGMENT>
}
}
return min;
}

Algorithms Removing sequencing,


can be selection, and iteration from an
created in all algorithm.
the following
ways except:

Using existing Removes procedural


algorithms as abstraction.
building
blocks for
new
algorithms
has all the
following
benefits
except:

What is one Simplifies creating a complex


of the program.
benefits of
using a library
in a program?

Which call of moveElement("button1",


the function "down", 25);
correctly
follows the
instructions laid
out in the API?

// moves a
given element
on the screen
// id (string) -
the element ID
for the item to
be moved
// direction
(string) - the
direction the
element should
be moved
// amount
(number) - the
amount of pixels
the element
should be
moved

function
moveElement(id,
direction,
amount) {
var xPosition =
getXPosition(id);
var yPosition =
getYPosition(id);

if (direction ==
"left") {
setProperty(id,
"x", xPosition -
amount);
} else if
((direction ==
"right")) {
setProperty(id,
"x", xPosition +
amount);
} else if
((direction ==
"up")) {
setProperty(id,
"y", yPosition -
amount);
} else {
setProperty(id,
"y", yPosition +
amount);
}
}

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

About us For students For teachers Resources

About Quizlet Flashcards Live Help center

How Quizlet works Test Checkpoint Sign up

Careers Learn Blog Honor code

Advertise with us Solutions Be the Change Community guidelines

Get the app Q-Chat: your AI tutor Quizlet Plus for teachers Privacy

Spaced Repetition Terms

Modern Learning Lab Ad and Cookie Policy

Quizlet Plus Quizlet for Schools

Language

English (USA)

Country

United States Canada United Kingdom Australia New Zealand Germany France Spain Italy

Japan South Korea India China Mexico Sweden Netherlands Switzerland Brazil Poland

Turkey Ukraine Taiwan Vietnam Indonesia Russia

© 2024 Quizlet, Inc.

You might also like