Unit 7 Com Sci

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards

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

A. num % 2 == 0;

B. num % 0 == 2;

C. num % 1 == 0;

D. num % 1 == 2;

A. num % 2 == 0;

2
New cards

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

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

3
New cards

which function calls would provide the most helpfu test of this function?

function findMin (num1,num2){

if (num1 < num2){

return num1:

}else{

return num2;

D. findMin(-1,1)

findMin(1,-1)

findMin(1,1)

4
New cards

7.

What is printed to the console?

console.log(15 % 4);

A. 2

B. 3

C. 4

D. 1

B. 3

5
New cards

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. parameter

D. library

A. procedural abstraction

6
New cards

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?

function checkVowel(character){ var vowels = ["a", "e", "i", "o", "u"]; for(var i=0; i

C. OPTION C

7
New cards

10.

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

function min(numList){ var min = numList[0]; for(var i=0; i

A. numList[i] = min;

B. min = numList[i];

C. min = numList;

D. numList = min;

B. min = numList[i];

8
New cards

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

C. removing sequencing, selection, and iteration from an algorithm

9
New cards

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

D. removes procedural abstraction

10
New cards

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

A. simplifies creating a complex program

11
New cards

14.

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

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

12
New cards

15.

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

A. modularity

B. iteration

C. API

D. documentation

A. modularity

13
New cards

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

} bfunction solveMaze( )

{ moveForward();

moveForward();

rotateRight ();

while (canMove("forward")){ moveForward(); } rotateLeft();

moveForward();

14
New cards

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

simpli!es creating a complex program

15
New cards

Library

a group of functions (procedures) that may be used in creating new programs

16
New cards

Argument

the value passed to the parameter

17
New cards

Return

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.

18
New cards

API

Application Program Interface - specifications for how functions in a library behave and can be used

19
New cards

Modularity

The subdivision of a computer program into separate subprograms