AP CLASSROOM PRACTICE TESTS AND FINAL QS

¡Supera tus tareas y exámenes ahora con Quizwiz!

Consider the following procedure. PROCEDURE doSomething(num1, num2) { DISPLAY(num1) RETURN(num1) DISPLAY(num2) } Consider the following statement. DISPLAY(doSomething(10, 20)) What is displayed as a result of executing the statement above? A 10 10 B 10 20 C 10 10 20 D 10 20 10

A 10 10

Which of the following best describes the role of the Internet Engineering Task Force (IETF) ? A Developing standards and protocols for Internet communication B Preventing copyrighted materials from being illegally distributed online C Preventing malicious software from being distributed online D Verifying the ownership of encrypted keys used in secured messages

A Developing standards and protocols for Internet communication EXPLANATION: This option is correct. The IETF develops and oversees standards such as hypertext transfer protocol (HTTP), Internet protocol (IP), and simple mail transfer protocol (SMTP).

Which of the following are true statements about how the Internet enables crowdsourcing? I. The Internet can provide crowdsourcing participants access to useful tools, information, and professional knowledge. II. The speed and reach of the Internet can lower geographic barriers, allowing individuals from different locations to contribute to projects. III. Using the Internet to distribute solutions across many users allows all computational problems to be solved in reasonable time, even for very large input sizes. A I and II only B I and III only C II and III only D I, II, and III

A I and II only

The following code segment moves the robot around the grid. Assume that n is a positive integer. Line 1: count ←← 0 Line 2: REPEAT n TIMES Line 3: { Line 4: REPEAT 2 TIMES Line 5: { Line 6: MOVE_FORWARD() Line 7: } Line 8: ROTATE_RIGHT() Line 9: } Consider the goal of modifying the code segment to count the number of squares the robot visits before execution terminates. Which of the following modifications can be made to the code segment to correctly count the number of squares the robot moves to? A Inserting the statement count ←← count + 1 between line 6 and line 7 B Inserting the statement count ←← count + 2 between line 6 and line 7 C Inserting the statement count ←← count + 1 between line 8 and line 9 D Inserting the statement count ←← count + n between line 8 and line 9

A Inserting the statement count ←← count + 1 between line 6 and line 7

Which of the following algorithms display all integers between 1 and 20, inclusive, that are not divisible by 3 ? Select two answers. A Step 1:Set x to 0. Step 2:Increment x by 1. Step 3:If x is not divisible by 3, then display x. Step 4:Repeat steps 2 and 3 until x is 20. B Step 1:Set x to 0.Step 2: If x is divisible by 3, then display x.Step 3:Increment x by 1. Step 4: Repeat steps 2 and 3 until x is greater than 20. C Step 1:Set x to 1. Step 2: If x is divisible by 3, then do nothing; otherwise display x.Step 3:Increment x by 1. Step 4: Repeat steps 2 and 3 until x is 20. D Step 1:Set x to 1. Step 2: If x is divisible by 3, then do nothing; otherwise display x.Step 3:Increment x by 1. Step 4: Repeat steps 2 and 3 until x is greater than 20.

A Step 1:Set x to 0. Step 2:Increment x by 1. Step 3:If x is not divisible by 3, then display x. Step 4:Repeat steps 2 and 3 until x is 20. D Step 1:Set x to 1. Step 2: If x is divisible by 3, then do nothing; otherwise display x.Step 3:Increment x by 1. Step 4: Repeat steps 2 and 3 until x is greater than 20.

The list listOne is a sorted list of numbers that contains 700 elements. The list listTwo is a sorted list of numbers that contains 900 elements. Let x represent the maximum number of list elements that will need to be examined when performing a binary search for a value in listOne, and let y represent the maximum number of list elements that will need to be examined when performing a binary search for a value in listTwo. Which of the following statements about x and y is true? A The value of x is approximately equal to the value of y. B The value of x is approximately 10 less than the value of y. C The value of x is approximately 13 less than the value of y. D The value of x is approximately 200 less than the value of y.

A The value of x is approximately equal to the value of y. EXPLANATION: The binary search algorithm starts at the middle of the list and repeatedly eliminates half of the elements until the desired value is found or all elements have been eliminated. For listOne, the list will be cut in half a maximum of 9 times, with a total of 10 elements needing to be examined. The list will start with 700 elements, then will be reduced to 350 elements, then to 175 elements, then to 87 elements, then to 43 elements, then to 21 elements, then to 10 elements, then to 5 elements, then to 2 elements, and then, finally, to 1 element. For listTwo, the list will also be cut in half a maximum of 9 times, with a total of 10 elements needing to be examined. The list will start with 900 elements, then will be reduced to 450 elements, then to 225 elements, then to 112 elements, then to 56 elements, then to 28 elements, then to 14 elements, then to 7 elements, then to 3 elements, and then, finally, to 1 element.

Which of the following best describes the purpose of machine learning programs? A To analyze large data sets, recognize patterns, and make predictions based on data B To automatically translate algorithms from natural language to machine language C To determine whether an algorithm can be constructed to answer "yes" or "no" for all possible inputs D To find approximate solutions to problems that would otherwise require an unreasonably long amount of time to solve

A To analyze large data sets, recognize patterns, and make predictions based on data This option is correct. Machine learning is the process of a computer analyzing data in order to make predictions and decisions based on trends in the data.

Assume that the string oldString contains at least 4 characters. A programmer is writing a code segment that is intended to remove the first two characters and the last two characters from oldString and assign the result to newString. For example, if oldString contains "student", then newString should contain "ude". Which of the following code segments can be used to assign the intended string to newString ? Select two answers. A newString ← substring(oldString, 3, len(oldString) - 4) B newString ← substring(oldString, 3, len(oldString) - 2) C tempString ← substring(oldString, 3, len(oldString) - 2) newString ← substring(tempString, 1, len(tempString) - 2) D tempString1 ← substring(oldString, 1, 2) tempString2 ← substring(oldString, len(oldString) - 2, 2) newString ← concat(tempString1, tempString2)

A newString ← substring(oldString, 3, len(oldString) - 4) D. tempString1 ← substring(oldString, 1, 2) tempString2 ← substring(oldString, len(oldString) - 2, 2) newString ← concat(tempString1, tempString2)

Which of the following statements describe how cloud computing has affected Internet communication? Select two answers. A Cloud computing has eliminated the need to provide redundancy in Internet routing. B Cloud computing has helped enhance collaboration. C Cloud computing has introduced new data-security concerns. D Cloud computing has reduced concerns about intellectual property rights.

B Cloud computing has helped enhance collaboration. C Cloud computing has introduced new data-security concerns.

For which of the following situations would it be best to use a heuristic in order to find a solution that runs in a reasonable amount of time? A Appending a value to a list of n� elements, which requires no list elements be examined. B Finding the fastest route that visits every location among n� locations, which requires n!�! possible routes be examined. C Performing a binary search for a score in a sorted list of n� scores, which requires that fewer than n� scores be examined. D Performing a linear search for a name in an unsorted database of n� people, which requires that up to n� entries be examined.

B Finding the fastest route that visits every location among n� locations, which requires n!�! possible routes be examined.

The owner of a clothing store records the following information for each transaction made at the store during a 7-day period. The date of the transaction The method of payment used in the transaction The number of items purchased in the transaction The total amount of the transaction, in dollars Customers can pay for purchases using cash, check, a debit card, or a credit card. Using only the data collected during the 7-day period, which of the following statements is true? A The average amount spent per day during the 7-day period can be determined by sorting the data by the total transaction amount, then adding the 7 greatest amounts, and then dividing the sum by 7. B The method of payment that was used in the greatest number of transactions during the 7-day period can be determined by sorting the data by the method of payment, then adding the number of items purchased for each type of payment method, and then finding the maximum sum. C The most expensive item purchased on a given date can be determined by searching the data for all items purchased on the given date and then sorting the matching items by item price. D The total number of items purchased on a given date can be determined by searching the data for all transactions that occurred on the given date and then adding the number of items purchased for each matching transaction.

B The method of payment that was used in the greatest number of transactions during the 7-day period can be determined by sorting the data by the method of payment, then adding the number of items purchased for each type of payment method, and then finding the maximum sum.

Consider the following code segment. firstList ← ["guitar", "drums", "bass"] secondList ← ["flute", "violin"] thirdList ← [] thirdList ← firstList firstList ← secondList secondList ← thirdList What are the contents of secondList after the code segment is executed? A [ ] B ["guitar", "drums", "bass"] C ["flute", "violin"] D ["flute", "violin", "guitar", "drums", "bass"]

B ["guitar", "drums", "bass"]

Consider the following code segment. theList ← [-2, -1, 0, 1, 2] count1 ← 0 count2 ← 0 FOR EACH value IN theList { IF(value > 0) { count1 ← count1 + 1 } ELSE { count2 ← count2 + 1 } } What are the values of count1 and count2 as a result of executing the code segment? A count1 = 2, count2 = 2 B count1 = 2, count2 = 3 C count1 = 3, count2 = 2 D count1 = 5, count2 = 0

B count1 = 2, count2 = 3

Three words are stored in the variables word1, word2, and word3. The values of the variables are to be updated as shown in the following table. VariableValue BeforeUpdatingValue AfterUpdatingword1"xylophone""zebra"word2"yarn""yarn"word3"zebra""xylophone" Which of the following code segments can be used to update the values of the variables as shown in the table? A temp ← word1 word3 ← word1 word1 ← temp B temp ← word1 word1 ← word3 word3 ← temp C temp ← word1 word1 ← word2 word2 ← word3 word3 ← temp D temp ← word3 word3 ← word2 word2 ← word1 word1 ← temp

B temp ← word1 word1 ← word3 word3 ← temp

Which of the following algorithms will allow the robot to make a single circuit around the rectangular region of black squares, finishing in the exact location and direction that it started in each of the four grids? A Step 1:Keep moving forward, one square at a time, until the square to the right of the robot is black.Step 2:Turn right and move one square forward.Step 3:Repeat steps 1 and 2 three more times. B Step 1:Keep moving forward, one square at a time, until the square to the right of the robot is no longer black.Step 2:Turn right and move one square forward. Step 3: Repeat steps 1 and 2 three more times. C Step 1:Move forward three squares.Step 2:Turn right and move one square forward.Step 3: If the square to the right of the robot is black, repeat steps 1 and 2. D Step 1:Move forward three squares.Step 2:Turn right and move one square forward.Step 3:If the square to the right of the robot is not black, repeat steps 1 and 2.

B. Step 1: Keep moving forward, one square at a time, until the square to the right of the robot is no longer black. Step 2: Turn right and move one square forward. Step 3: Repeat steps 1 and 2 three more times. EXPLANATION: Correct. In all four grids, the robot starts along the side of a black region. Step 1 moves the robot just past the end of the black region. Step 2 rotates the robot to the right and moves it forward, placing the robot along the next side of the black region. Step 3 will repeat steps 1 and 2 to move the robot around the other 3 sides to complete a circuit around the black region.

In the following code segment, assume that x and y have been assigned integer values. sum ←← 0 REPEAT x TIMES { REPEAT y TIMES { sum ←← sum + 1 } } At the end of which of the following code segments is the value of sum the same as the value of sum at the end of the preceding code segment? Select two answers. A sum ←← 0 z ←← x + y REPEAT z TIMES { sum ←← sum + 1 } B sum ←← 0 z ←← x * y REPEAT z TIMES { sum ←← sum + 1 } C sum ←← 0 REPEAT x TIMES { sum ←← sum + 1 } REPEAT y TIMES { sum ←← sum + 1 } D sum ←← 0 REPEAT y TIMES { REPEAT x TIMES { sum ←← sum + 1 } }

B. sum ←← 0 z ←← x * y REPEAT z TIMES { sum ←← sum + 1 } D. sum ←← 0 REPEAT y TIMES { REPEAT x TIMES { sum ←← sum + 1 } }

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 A procedure containsNegatives, which returns true if any negative values appear in the column and returns false otherwise. B A procedure countNegatives, which returns the number of negative values that appear in the column. C 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. D A procedure minimum, which returns the minimum value that appears in the column.

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

Consider the following code segment, which is intended to store ten consecutive even integers, beginning with 2, in the list evenList. Assume that evenList is initially empty. i ← 1 REPEAT 10 TIMES { <MISSING CODE> } Which of the following can be used to replace <MISSING CODE> so that the code segment works as intended? A APPEND(evenList, i) i ← i + 2 B i ← i + 2 APPEND(evenList, i) C APPEND(evenList, 2 * i) i ← i + 1 D i ← i + 1 APPEND(evenList, 2 * i)

C APPEND(evenList, 2 * i) i ← i + 1

A programmer is creating an algorithm that will be used to turn on the motor to open the gate in a parking garage. The specifications for the algorithm are as follows. The gate should not open when the time is outside of business hours. The motor should not turn on unless the gate sensor is activated. The motor should not turn on if the gate is already open. Which of the following algorithms can be used to open the gate under the appropriate conditions? A Check if the time is outside of business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is closed. If it is, turn on the motor. B Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is, turn on the motor. C Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is not, check if the gate is open. If it is not, turn on the motor. D Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is not, turn on the motor.

C Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is not, check if the gate is open. If it is not, turn on the motor.

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. health ←← health + 10 IF(health > 100) { health ←← 100 } food ←← food + 1 IF(food > 80) { food ←← 80 } knowledge ←← knowledge + 5 IF(knowledge > 25) { knowledge ←← 25 } The game program's author would like to write a procedure that could be used to update any variable in the game (myScore) that has a maximum value (myLimit) by a given amount (myAmount). A correct call of the procedure is shown below. myScore ←← updateScore(myScore, myAmount, myLimit) Which of the following is a correct implementation of updateScore ? A PROCEDURE updateScore(score, amount, limit) { score ←← score + amount IF (score > limit) { score ←← limit } } B PROCEDURE updateScore(score, amount, limit) { score ←← score + amount IF(score > amount) { score ←← limit } RETURN(limit) } C PROCEDURE updateScore(score, amount, limit) { score ←← score + amount IF(score > limit) { score ←← limit } RETURN(score) } D PROCEDURE updateScore(score, amount, limit) { IF(score = health) { score ←← score + 10 } IF(score = food) { score ←← score + 1 } IF(score = knowledge) { score ←← score + 5 } IF(score > limit) { score ←← limit } }

C PROCEDURE updateScore(score, amount, limit) { score ←← score + amount IF(score > limit) { score ←← limit } RETURN(score) } EXPLANATION: This procedure adds the correct amount to the score to be updated. If the score to be updated is larger than the limit, the score's value is set to the limit. The updated value is returned.

Which of the following are benefits of procedural abstraction? Select two answers. A Procedural abstraction prevents programmers from accidentally using the intellectual property of other programmers. B Procedural abstraction eliminates the need for programmers to document their code. C Procedural abstraction makes it easier for people to read computer programs. D Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block.

C Procedural abstraction makes it easier for people to read computer programs. D Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block.

Consider the following procedures for string manipulation. Procedure Call Explanation: concat(str1, str2)Returns a single string consisting of str1 followed by str2. For example, concat("key", "board") returns "keyboard". reverse(str)Returns the reverse of the string str. For example, reverse("abcd") returns "dcba". Which of the following code segments can be used to store "noon" in the string variable word ? A word ← "no" word ← concat(reverse(word), word) B word ← "no" word ← concat(reverse(word), reverse(word)) C word ← "on" word ← concat(reverse(word), word) D word ← "on" word ← concat(reverse(word), reverse(word))

C word ← "on" word ← concat(reverse(word), word)

Consider the following code segment. Assume that index1 is a number between 1 and LENGTH(theList), inclusive, and index2 is a number between 2 and LENGTH(theList) - 1, inclusive. theList ← [9, -1, 5, 2, 4, 8] x ← theList[index1] + theList[index2] What is the largest possible value that the variable x can have after the code segment executes? A.17 B.14 C.11 D.4

C. 11

Consider the following code segment. result ← 1 IF(score1 > 500) { result ← result + 1 IF(score2 > 500) { result ← result + 1 } ELSE { result ← result + 2 } } ELSE { result ← result + 5 IF(score2 > 500) { result ← result + 1 } ELSE { result ← result - 1 } } If the value of score1 is 350 and the value of score2 is 210, what will be the value of result after the code segment is executed? A.3 B.4 C.5 D.7

C.5

Which of the following actions could be used to help reduce the digital divide? I. Providing free education and training on how to use computing devices II. Providing free or low-cost computing devices to low-income individuals III. Providing networks and infrastructure to people in remote areas A III only B I and II only C II and III only D I, II, and III

D I, II, and III

Suppose a large group of people in a room were all born in the same year. Consider the following three algorithms, which are each intended to identify the people in the room who have the earliest birthday based on just the month and day. For example, a person born on February 10 is considered to have an earlier birthday than a person born on March 5. Which of the three algorithms will identify the correct people? i. All the people in the room stand up. All standing people form pairs where possible, leaving at most one person not part of a pair. For each pair, the person with the earlier birthday remains standing, while the other person in the pair sits down. If there is a tie, both people sit down. Any individual not part of a pair remains standing. Continue doing this until only one person remains standing. That person has the earliest birthday. II. All the people in the room stand up. All standing people form pairs with another standing person that they have not previously been paired with where possible, leaving at most one person not part of a pair. For each pair, the person with the earlier birthday remains standing, while the other person in the pair sits down. If there is a tie, both people in the pair remain standing. Any individual not part of a pair remains standing. Continue doing this until only one person remains standing or all persons standing have the same birthday. Anyone still standing has the earliest birthday. III. Beginning with the number 1, ask if anyone was born on that day of any month. Continue with the numbers 2, 3, and so on until a positive response is received. If only one person responds, that person has the earliest birthday. If more than one person responds, determine which person was born in the earliest month, and that person or those persons have the earliest birthday. A I only B II only C I and II D II and III

D II and III EXPLANATION: Incorrect. Algorithm III does not work correctly. Algorithm III chooses the person(s) with the earliest day, disregarding the month. For example, algorithm III will incorrectly determine that a person born on February 1 has an earlier birthday than a person born on January 5.

Three different numbers need to be placed in order from least to greatest. For example, if the numbers are ordered 9, 16, 4, they should be reordered as 4, 9, 16. Which of the following algorithms can be used to place any three numbers in the correct order? A If the first number is greater than the last number, swap them. Then, if the first number is greater than the middle number, swap them. B If the first number is greater than the middle number, swap them. Then, if the middle number is greater than the last number, swap them. C If the first number is greater than the middle number, swap them. Then, if the middle number is greater than the last number, swap them. Then, if the first number is greater than the last number, swap them. D If the first number is greater than the middle number, swap them. Then, if the middle number is greater than the last number, swap them. Then, if the first number is greater than the middle number, swap them.

D If the first number is greater than the middle number, swap them. Then, if the middle number is greater than the last number, swap them. Then, if the first number is greater than the middle number, swap them. Correct. After comparing the first number and the middle number and potentially swapping them, and then comparing the middle number and the last number and potentially swapping them, the largest number will be in the third position. Next, after comparing the first number and the middle number and potentially swapping them, the three numbers will be ordered from least to greatest.

Which of the following best describes one of the benefits of using an iterative and incremental process of program development? A It allows programmers to implement algorithmic solutions to otherwise unsolvable problems. B It eliminates the need for programmers to test completed programs. C It enables programmers to create programs that use the lowest-level abstractions available. D It helps programmers identify errors as components are added to a working program.

D It helps programmers identify errors as components are added to a working program

A student wants to create an algorithm that can determine, given any program and program input, whether or not the program will go into an infinite loop for that input. The problem the student is attempting to solve is considered an undecidable problem. Which of the following is true? A It is possible to create an algorithm that will solve the problem for all programs and inputs, but the algorithm can only be implemented in a low-level programming language. B It is possible to create an algorithm that will solve the problem for all programs and inputs, but the algorithm requires simultaneous execution on multiple CPUs. C It is possible to create an algorithm that will solve the problem for all programs and inputs, but the algorithm will not run in reasonable time. D It is not possible to create an algorithm that will solve the problem for all programs and inputs.

D It is not possible to create an algorithm that will solve the problem for all programs and inputs.

When the robot reaches the gray square, it turns around and faces the bottom of the grid. Which of the following changes, if any, should be made to the code segment to move the robot back to its original position in the bottom-left square of the grid and facing toward the bottom of the grid? A Interchange the ROTATE_RIGHT and the ROTATE_LEFT blocks. B Replace ROTATE_RIGHT with ROTATE_LEFT. C Replace ROTATE_LEFT with ROTATE_RIGHT. D No change is needed; the algorithm is correct as is.

D No change is needed; the algorithm is correct as is.

A computer program contains code in several places that asks a user to enter an integer within a specified range of values. The code repeats the input request if the value that the user enters is not within the specified range. A programmer would like to create a procedure that will generalize this functionality and can be used throughout the program. The correct use of the procedure is shown below, where min is the least acceptable value, max is the greatest acceptable value, and promptString is the string that should be printed to prompt the user enter a value. inputVal ←← getRange(min, max, promptString) Which of the following is a correct implementation of the getRange procedure? A PROCEDURE getRange(min, max, promptString) { DISPLAY(promptString) RETURN(INPUT()) } B PROCEDURE getRange(min, max, promptString) { DISPLAY(promptString) x ←← INPUT() RETURN(x) } C PROCEDURE getRange(min, max, promptString) { DISPLAY(promptString) x ←← INPUT() REPEAT UNTIL(x ≥ min AND x ≤ max) { DISPLAY(promptString) x ←← INPUT() } } D PROCEDURE getRange(min, max, promptString) { DISPLAY(promptString) x ←← INPUT() REPEAT UNTIL(x ≥ min AND x ≤ max) { DISPLAY(promptString) x ←← INPUT() } RETURN(x) }

D PROCEDURE getRange(min, max, promptString) { DISPLAY(promptString) x ←← INPUT() REPEAT UNTIL(x ≥ min AND x ≤ max) { DISPLAY(promptString) x ←← INPUT() } RETURN(x) } EXPLANATION: This implementation prompts the user and accepts the user's input. For as long as the user's input is outside of the valid range, the program repeats the prompt and the call to the INPUT procedure. When the loop terminates, the last input value is returned.

A teacher has a goal of displaying the names of 2 students selected at random from a group of 30 students in a classroom. Any possible pair of students should be equally likely to be selected. Which of the following algorithms can be used to accomplish the teacher's goal? A Step 1:Assign each student a unique integer from 1 to 30.Step 2:Generate a random integer n from 1 to 15.Step 3:Select the student who is currently assigned integer n and display the student's name.Step 4:Generate a new random integer n from 16 to 30.Step 5:Select the student who is currently assigned integer n and display the student's name. B Step 1:Assign each student a unique integer from 1 to 30.Step 2:Generate a random integer n from 1 to 30.Step 3:Select the student who is currently assigned integer n and display the student's name.Step 4:Generate a new random integer n from 1 to 30.Step 5:Select the student who is currently assigned integer n and display the student's name. C Step 1:Assign each student a unique integer from 1 to 30.Step 2:Generate a random odd integer n from 1 to 29.Step 3:Select the student who is currently assigned integer n and display the student's name.Step 4:Generate a new random even integer n from 2 to 30.Step 5:Select the student who is currently assigned integer n and display the student's name. D Step 1:Assign each student a unique integer from 1 to 30.Step 2:Generate a random integer n from 1 to 30.Step 3:Select the student who is currently assigned integer n and display the student's name.Step 4:The student who was selected in the previous step is assigned 0. All other students are reassigned a unique integer from 1 to 29.Step 5:Generate a new random integer n from 1 to 29. Step 6:Select the student who is currently assigned integer n and display the student's name.

D Step 1:Assign each student a unique integer from 1 to 30.Step 2:Generate a random integer n from 1 to 30.Step 3:Select the student who is currently assigned integer n and display the student's name.Step 4:The student who was selected in the previous step is assigned 0. All other students are reassigned a unique integer from 1 to 29.Step 5:Generate a new random integer n from 1 to 29. Step 6:Select the student who is currently assigned integer n and display the student's name.

A student wrote the procedure below, which is intended to ask whether a user wants to keep playing a game. The procedure does not work as intended. PROCEDURE KEEP PLAYING DISPLAY DO YOU WANT TO KEEP PLAYING(Y/N?) IF RESPONSE = Y AND RESPONSE = YES RETURN TRUE ELSE RETURN FALSE Which of the following best describes the result of running the procedure? A The procedure returns when the user inputs the value and returns otherwise. B The procedure returns when the user inputs the value and returns otherwise. C The procedure returns no matter what the input value is. D The procedure returns no matter what the input value is.

D The procedure returns no matter what the input value is. EXPLANATION: This option is correct. The expression always evaluates to because it is not possible for the variable to be equal to both . Therefore, the procedure will alwaysreturn FALSE

A musician is creating a song using audio samples. Which of the following actions will minimize the risk of a copyright violation when creating sample-based music? A Using samples found on popular music-streaming sites B Using samples found on peer-to-peer networks C Using samples from nondigital sound sources (vinyl records, tapes, etc.) D Using samples published with a no-rights-reserved Creative Commons license

D Using samples published with a no-rights-reserved Creative Commons license EXPLANATION: This option is correct. Creative Commons licenses can be used by creators of digital music to specify how the samples can be used by others. A no-rights-reserved license allows others to freely make use of the samples.

Consider the goal of using the device to produce the following drawing, where each line shown has a length of 10 units and the horizontal lines are 10 units apart. The device is positioned at the upper-left corner of a sheet of paper and is facing right. Which of the following code segments will produce the drawing shown? ------------------------------- ------------------------------- A penDown() goForward(10) turnRight(90) goForward(10) turnRight(90) goForward(10) B penDown() goForward(10) penUp() turnRight(90) turnRight(90) penDown() goForward(10) C penDown() goForward(10) turnRight(90) penUp() goForward(10) turnRight(90) penDown() D penDown() goForward(10) penUp() turnRight(90) goForward(10) turnRight(90) penDown() goForward(10)

D penDown() goForward(10) penUp() turnRight(90) goForward(10) turnRight(90) penDown() goForward(10)

Consider the following code segment. Which of the following CANNOT be displayed as a result of executing the code segment? A 1 1 1 1 B 1 2 3 2 C 1 2 3 4 D 1 3 2 4

D 1 3 2 4

Grades in a computer science course are based on total points earned on a midterm exam and a final exam. The teacher provides a way for students to improve their course grades if they receive high scores on the final exam: if a student's final exam score is greater than the student's midterm exam score, the final exam score replaces the midterm exam score in the calculation of total points. The table below shows two students' scores on the midterm and final exams and the calculated total points each student earns. Khalil does better on the midterm exam than on the final exam, so his original midterm and final exam scores are added to compute his total points. Josefina does better on the final exam than on the midterm exam, so her final exam score replaces her midterm exam score in the total points calculation. The teacher has data representing the scores of thousands of students. For each student, the data contain the student name, the midterm exam score, the final exam score, and the result of the total points calculation. Which of the following could be determined from the data? I. The average total points earned per student II. The average increase in total points per student as a result of the score replacement policy III. The proportion of students who improved their total points as a result of the score replacement policy A III only B I and II only C I and III only D I, II, and III

D. I, II AND III EXPLANATION:This option is correct. The average total points earned per student can be determined using the result of the total points calculationfor each student. The average increase in total points per student as a result of the score replacement policy can be determined bycalculating the differences between each student score before and after the replacement policy was applied. The proportion of studentswho improved their total points as a result of the score replacement policy can be determined by comparing the midterm and final scores for each student with the result of the total points calculation.


Conjuntos de estudio relacionados

Psych Final - Childhood Disorders, Eating Disorders, Bipolar Disorder, Depressive Disorders, Schizophrenia, Neurocognitive Disorders, Personality Disorders, Substance Use

View Set

Advanced nutrition and wellness south and eastern asia study guide

View Set

MEA1304 QUIZZES FOR FINAL CH 6-10

View Set

ACG 2071 Test 3 Multi Choice (Chapter 11)

View Set