1/51
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
what helps when writing code?
better organization
how does better organization help with code?
helps to debug and build upon
functions that have what, help simplify code?
parameters and return values
how many values can functions return at once?
only one
what is a parameter?
a variable in a function definition that is used as a placeholder for values that will be passed through the function
what is an argument?
the value passed to the parameter
what does a return do?
it is used to return the flow of control to the point where the function was called. it also returns the value of an expression.
what is MOD used for?
to determine if a number is divisible by another number
what is procedural abstraction
the process of extracting shared features to generalize functionality
using parameters allows what?
it allows the functions to be generalized
using procedural abstraction helps what?
it helps improve code readability
what do parameters and return values help us do?
they help us write code that is neater, and works in a larger number of scenarios
what is a library?
a collection of functions that can be used in many different programs
a library should include what?
how each function works, a complete list of procedures, and what (if anything) will be returned, those are called API's
what is an API?
specifications for how the functions in a library behave and can be used
why is testing useful?
it helps the user understand the behavior of the function and is helpful for debugging
what are some benefits of using algorithms?
they help reduce development time, testing, and they simplify the finding of errors
what is modularity?
the subdivision of a computer program into separate programs
what do libraries help with?
they help the programmer collaborate, reuse code, and write simple programs
what do parameters help with?
they allow functions to run in predictable ways without impacting anything, help communicate what the code is supposed to do, and they make functions more flexible
The procedure below will be called twice with two numbers provided as arguments to the parameter myNumber. Which of the following pair of numbers will mystery return the same value?
100 and 200
Using existing algorithms as building blocks for new algorithms has all the following benefits EXCEPT:
removes procedural abstraction
Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems?
procedural abstraction
What will be printed to the console after this program runs?
[0, 3, 6, -1, 9]
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;
Algorithms can be created in all the following ways EXCEPT:
removing sequencing, selection, and iteration from an algorithm
Which call of the function correctly follows the instructions laid out in the API?
moveElement("button1", "down", 25);
This function finds the minimum number in a list. What should
function min(numList){
var min = numList[0];
for(var i=0; i
}
}
return min;
}
min = numList[i];
You have imported a library with the birthMonth() function. Based on the API, how many strings are entered to calculate the birth month?
-3
-0
-4
-1
1
The figure below shows a robot in a grid of squares. The robot is represented as a triangle, which is initially facing upward. The robot can move into a white or gray square but cannot move into a black region.
MoveAndTurn 2, 1
MoveAndTurn 4, 3
MoveAndTurn 2, 0
A game program contains the following code to update three score variables, health, food, and knowledge. The maximum values for the three variables are 100, 80, and 25, respectively.
PROCEDURE updateScore(score, amount, limit){
score ← score + amount
IF(score > limit){
score ← limit
}
RETURN(score)
Which of the following are benefits of procedural abstraction?
Procedural abstraction makes it easier for people to read computer programs.
Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block.
Which of the following code segments can be used to draw the figure?
x ← 4
y ← 1
r ← 0
REPEAT 3 TIMES{
r ← r + 1
y ← y + 1
drawCircle(x, y, r)
}
x ← 4
y ← 4
r ← 3
REPEAT 3 TIMES{
drawCircle(x, y, r)
y ← y - 1
r ← r - 1
}
A student has a data file containing 10,000 numerical values. The student is writing a program to compute the average of the numbers contained in the file. Which of the following procedures is most likely to be useful in the student's program?
A procedure that returns the sum of the values in the file
Let the value of the variable x be 2, the value of the variable y be 2, and the value of the variable r be 1. Which of the following code segments can be used to draw the figure?
drawCircle(x, y, r)
drawCircle(x, y + 3, r)
drawCircle(x + 3, y, r)
drawCircle(x + 3, y + 3, r)
Which of the following procedures would be most useful as part of a program to determine whether a word appears in two different text files?
A procedure isFound, which takes a word and a text file as input and returns true if the word appears in the text file
What is displayed as a result of the procedure call proc2("birthday", "to you") ?
to you happy birthday
A student is writing a program that is intended to replace each negative value in a particular column of a spreadsheet with the value 0. Which of the following procedures is most likely to be useful in the student's program?
A procedure findNegative, which returns the row number of the first negative value that appears in the column or -1 if there are no negative values.
An error was made in writing this function so that it does not work as intended. Which line of code would need to be fixed in order for the function to work as designed?
Line 03
Line 06
Line 011
Line 08
Line 03
Which function calls would provide the most helpful test of this function?
findMin(-1,1)findMin(1,-1)findMin(1,1)
Is the following function is a good candidate to be placed in a library?
No. It references variables ( player1Points , player2Points ) that are most likely global variables in the original program.
What will print to the console after running this code segment?
18
16
15
21
16
What is printed to the console?console.log(15 % 4)
3
2
4
1
3
A computer science student completes a program and asks a classmate for feedback. The classmate suggests rewriting some of the code to include more procedural abstraction. Which of the following is NOT a benefit of procedural abstraction?
making the code run faster
Which of the following is a true statement about the student's use of the computer scientist's search procedure?
The student is reusing the computer scientist's procedural abstraction by knowing what the procedure does without knowing how it does it.
A/An ______ is the value passed to the parameter
argument
A/An ______ is used to return the flow of control to the point where the procedure (also known as a function) was called and to return the value of expression.
return
A/An ______ is a variable in a function definition and is used as a placeholder for values that will be passed through the function.
parameter
A/An ______ contains specifications for how functions in a library behave and can be used.
API
This provides a name for a process and allows the procedure (function) to be used only knowing what it does, and not necessarily how it does it.
procedural abstraction
A/An ______ is a group of functions (procedures) that may be used in creating new programs
library
which of the following procedures would be most useful as a part of a program that determines GPA?
calQuotient