Ap computer science

Ace your homework & exams now with Quizwiz!

Value of input1 Value of input2 Value of expression true true false true false true false true true false false true Which of the following expressions are equivalent to the value of expression as shown in the table? Select two answers. A.NOT input1) OR (NOT input2) b.(NOT input1) AND (NOT input2) c.NOT (input1 OR input2) D.NOT (input1 AND input2)

.the correct answer is A A is correct because Correct. When input1 and input2 are both true, the expressions (NOT input1) and (NOT input2) are both false, so (NOT input1) OR (NOT input2) will evaluate to false. In all other cases, either (NOT input1) or (NOT input2) (or both) will evaluate to true, so (NOT input1) OR (NOT input2) will evaluate to true. B is not the correct answer because Incorrect. For example, when input1 is true and input2 is false, then (NOT input1) will be false and (NOT input2) will be true. Therefore, (NOT input1) AND (NOT input2) will be false instead of the intended value true. c.is not correct because Incorrect. For example, when input1 is true and input2 is false, then (input1 OR input2) will be true. Therefore, NOT (input1 OR input2) will be false instead of the intended value true. D. is correct because Correct. When input1 and input2 are both true, the expression (input1 AND input2) is true, so NOT (input1 AND input2) will evaluate to false. In all other cases, (input1 AND input2) will evaluate to false, so NOT (input1 AND input2) will evaluate to true.

.The diagram below shows a circuit composed of two logic gates labeled OR and AND. Each gate takes two inputs and produces a single output. If the inputs A and C are both true, which of the following best describes the output of the AND gate? A.The output will be true no matter what the value of input B is. BThe output will be false no matter what the value of input B is. C.The output will be true if input B is true; otherwise it will be false. D.The output will be false if input B is true; otherwise it will be true.

A is the correct A is correct because This option is correct. Because the value of input A is true, the resulting value coming out of the OR gate must be true. Because the value of input C is true, the resulting value coming out of the AND gate is true. The value of input B did not affect this result. B is incorrect This option is incorrect. If input B is true, then the resulting value coming out of the OR gate will be true. Since the value of C is true, the resulting value coming out of the AND gate is true. This result contradicts the statement. C is not correct because This option is incorrect. If input B is false, the resulting value coming out of the OR gate will be true (since the value of A is true). Since the value of C is true, the resulting value coming out of the AND gate is true. This result contradicts the statement. D is not correct because This option is incorrect. If input B is true, then the resulting value coming out of the OR gate will be true. Since the value of C is true, the resulting value coming out of the AND gate is true. This result contradicts the statement.

A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is 50, then the scores 40, 44, 50, 58, and 60 are all within 10 points of the target, while 38 and 61 are not. Which of the following Boolean expressions will evaluate to true if and only if score is within 10 points of target ? A.(score ≤ target + 10) AND (target + 10 ≤ score) b.(target + 10 ≤ score) AND (score ≤ target - 10) C.(score ≤ target - 10) AND (score ≤ target + 10) D.(target - 10 ≤ score) AND (score ≤ target + 10)

D is correct A.Incorrect. This Boolean expression does not work as intended. For example, if score is 44 and target is 50, then (score ≤ target + 10) evaluates to true and (target + 10 ≤ score) evaluates to false. Therefore this Boolean expression will evaluate to false when it should evaluate to true. B.Incorrect. This Boolean expression does not work as intended. For example, if score is 44 and target is 50, then (target + 10 ≤ score) evaluates to false and (score ≤ target - 10) evaluates to false. Therefore this Boolean expression will evaluate to false when it should evaluate to true. .C.Incorrect. This Boolean expression does not work as intended. For example, if score is 44 and target is 50, then (score ≤ target - 10) evaluates to false and (score ≤ target + 10) evaluates to true. Therefore this Boolean expression will evaluate to false when it should evaluate to true. D.Correct. This Boolean expression is true if and only if score is between target - 10 and target + 10, inclusive. Therefore, it evaluates to true if and only if score is in the desired range.

Consider the following procedures. PROCEDURE proc1(str) { DISPLAY(str) DISPLAY("happy") } PROCEDURE proc2(str1, str2) { proc1(str2) DISPLAY(str1) } What is displayed as a result of the procedure call proc2("birthday", "to you") ? A birthday happy to you B birthday happy birthday C to you birthday happy D to you happy birthday

D is the correct answer A.Incorrect. In proc2, the call to proc1 occurs before the DISPLAY statement, so "to you" is displayed before "happy" and "birthday". B.Incorrect. This would be the result if the call to proc1 was proc1(str1) instead of proc1(str2). C.Incorrect. In proc2, the call to proc1 occurs before the DISPLAY statement, so "to you" and "happy" are displayed before "birthday". D.Correct. The call to proc2 assigns "birthday" to the parameter str1 and "to you" to the parameter str2. The first statement in proc2 calls proc1 and assigns "to you" to proc1's parameter str. The proc1 procedure displays the value of str ("to you") followed by "happy", then terminates execution and returns to the point in proc2 immediately following where proc1 was called. The proc2 procedure displays the value of str1 ("birthday") and then terminates execution.

the flow chart on the google doc Which of the following statements is equivalent to the algorithm in the flowchart?

correct answer A A is correct because The flowchart sets to whenever is greater than or equal , and sets to otherwise. Therefore, the algorithm is equivalent to . B is incorrect because This expression would be used for a flowchart to set to whenever is greater than and equal . This does not correctly set to in cases where only one of the two conditions is . c is incorrect because This expression would be used for a flowchart to set to whenever is less than or equal to or equals . D is incorrect because This expression would be used for a flowchart to set to whenever is less than or equal to and equals . look at AP for more help the answer i chose was B

Which of the following is NOT a possible value displayed by the program? A too high B in range C too low D out of range

the correct answer D A.Incorrect. For example, if n is initially 30, then the first IF will be true and n will be incremented by 1. The next IF condition will also be true because n is at least 1. The next IF condition will be true because n is at least 30. Therefore, "too high" will be displayed. B.Incorrect. For example, if n is initially 20, then the first IF condition will be true and n will be incremented by 1. The next IF condition will also be true because n is at least 1. The next IF condition will be false because n is less than 30. The next IF condition will be true because n is at least 10. Therefore, "in range" will be displayed. C.Incorrect. For example, if n is initially 5, then the first IF condition will be true and n will be incremented by 1. The next IF condition will also be true because n is at least 1. The next IF condition will be false because n is less than 30. The next IF condition will be false because n is less than 10. Therefore, "too low" will be displayed. D.Correct. The string "out of range" could only be displayed if the condition n ≥ 1 was false. If the initial value of n is at least 0, then n will be incremented by 1, making n at least 1. Therefore the condition n ≥ 1 will be true and "out of range" will not be displayed. If the initial value of n is negative, then n will be multiplied by -1, making n at least 1. Therefore the condition n ≥ 1 will be true and "out of range" will not be displayed.

Consider the following numeric values. Binary 1011 Binary 1101 Decimal 5 Decimal 12 Which of the following lists the values in order from least to greatest? A Decimal 5, binary 1011, decimal 12, binary 1101 B Decimal 5, decimal 12, binary 1011, binary 1101 C Decimal 5, binary 1011, binary 1101, decimal 12 D Binary 1011, binary 1101, decimal 5, decimal 12

the correct answer is A A.Correct. Binary 1011 is equivalent to 23+21+2023+21+20, or decimal 11, and binary 1101 is equivalent to 23+22+2023+22+20, or decimal 13. The order of the numbers (written in their equivalent decimal format) is 5, 11, 12, 13. B.Incorrect. Binary 1011 is equivalent to decimal 11 and should be placed before decimal 12. C.Incorrect. Binary 1101 is equivalent to decimal 13 and should be placed after decimal 12. D.Incorrect. Binary 1011 is equivalent to decimal 11 and should be placed after decimal 5. Binary 1101 is equivalent to decimal 13 and should be placed after decimal 12.

A user wants to save a data file on an online storage site. The user wants to reduce the size of the file, if possible, and wants to be able to completely restore the file to its original version. Which of the following actions best supports the user's needs?

the correct answer is A A.Correct. Lossless compression algorithms allow for complete reconstruction of the original data and typically reduce the size of the data. B.Incorrect. While a lossy compression algorithm will reduce the size of the data, it does not allow for complete reconstruction of the original data. C.Incorrect. Applying lossy compression the to file will prevent the user from restoring it to its original version. D.Incorrect. Uploading the original file allows complete reconstruction of the original data but does not reduce the size of the file.

A person wants to transmit an audio file from a device to a second device. Which of the following scenarios best demonstrates the use of lossless compression of the original file? A.A device compresses the audio file before transmitting it to a second device. The second device restores the compressed file to its original version before playing it. B.A device compresses the audio file by removing details that are not easily perceived by the human ear. The compressed file is transmitted to a second device, which plays it. C.C A device transmits the original audio file to a second device. The second device removes metadata from the file before playing it. D.A device transmits the original audio file to a second device. The second device plays the transmitted file as is.

the correct answer is A A.Correct. Lossless compression is a technique that allows for complete reconstruction of the original data. B.Incorrect. This technique is an example of lossy audio compression. C.Incorrect. Removing a file's metadata does not allow for reconstruction of the original data. D.Incorrect. This situation does not make use of any compression.

Procedure CallDrawLine (x1, y1, x2, y2) expalntion Draws a line segment on a coordinate grid with endpoints at coordinates (x1, y1) and (x2, y2) The DrawLine procedure is to be used to draw the following figure on a coordinate grid. The following code segment is intended to draw the figure. startX ← 2 startY ← 6 endX ← 8 endY ← 8 REPEAT 4 TIMES { <MISSING CODE> } Which of the following can be used to replace <MISSING CODE> so that the figure is drawn correctly? A.DrawLine (startX, startY, endX, endY) endY ←← endY - 2 B.DrawLine (startX, startY, endX, endY) endX ←← endX - 2 endY ←← endY - 2 C. endY ←← endY - 2 DrawLine (startX, startY, endX, endY) D.endX ←← endX - 2 endY ←← endY - 2 DrawLine (startX, startY, endX, endY)

the correct answer is A A.Correct. The code segment draws four line segments, each with a left endpoint at the coordinate (2, 6). The first line segment has a right endpoint at the coordinate (8, 8). The loop repeatedly subtracts two from endY, so that the subsequent line segments have their right endpoints at (8, 6), (8, 4), and (8, 2). B.Incorrect. This code segment will draw four line segments: one with endpoints (2, 6) and (8, 8), one with endpoints (2, 6) and (6, 6), one with endpoints (2, 6) and (4, 4), and one with endpoints (2, 6) and (2, 2). C.Incorrect. This code segment will draw four line segments: one with endpoints (2, 6) and (8, 6), one with endpoints (2, 6) and (8, 4), one with endpoints (2, 6) and (8, 2), and one with endpoints (2, 6) and (8, 0). D.Incorrect. This code segment will draw four line segments: one with endpoints (2, 6) and (6, 6), one with endpoints (2, 6) and (4, 4), one with endpoints (2, 6) and (2, 2), and one with endpoints (2, 6) and (0, 0).

Three teams (Team A, Team B, and Team C) are participating in a trivia contest. Let scoreA represent the number of correct questions for Team A, scoreB represent the number of correct questions for Team B, and scoreC represent the number of correct questions for Team C. Assuming no two teams get the same number of correct questions, which of the following code segments correctly displays the team with the highest number of correct questions?

the correct answer is A A.Correct. If scoreA is greater than both scoreB and scoreC (the first two IF clauses), then Team A wins. If scoreA is greater than scoreB but not greater than scoreC, then scoreC is greater than both scoreA and scoreB and Team C wins. If scoreB is greater than scoreA (the outer ELSE clause) and scoreC (the IF clause in the outer ELSE), then Team B wins. If scoreB is greater than scoreA but not greater than scoreC, then scoreC is greater than both scoreA and scoreB and Team C wins. B.Incorrect. For example, when scoreA > scoreC > scoreB, the code segment incorrectly identifies Team C as the winner instead of Team A. C.Incorrect. For example, when scoreC > scoreB > scoreA, the code segment incorrectly identifies Team B as the winner instead of Team C. D.Incorrect. For example, when scoreB > scoreC > scoreA, the code segment incorrectly identifies Team C as the winner instead of Team B.

Which of the following is an advantage of a lossless compression algorithm over a lossy compression algorithm? A lossless compression algorithm can guarantee that compressed information is kept secure, while a lossy compression algorithm cannot. B A lossless compression algorithm can guarantee reconstruction of original data, while a lossy compression algorithm cannot. C A lossless compression algorithm typically allows for faster transmission speeds than does a lossy compression algorithm. D A lossless compression algorithm typically provides a greater reduction in the number of bits stored or transmitted than does a lossy compression algorithm.

the correct answer is B A would not be correct because The ability to keep data secure is not a primary function of a compression algorithm. b is correct because Lossless compression algorithms are guaranteed to be able to reconstruct the original data, while lossy compression algorithms are not. c would be incorrect In situations where transmission time is maximally important, lossy compression algorithms are typically chosen, as lossy compression typically provides a greater reduction in file size. D would be incorrect Lossless compression algorithms usually achieve less reduction in the number of bits stored or transmitted than do lossy compression algorithms. the answer I chose was B

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 A procedure getWords, which takes a positive integer n and a text file as input and returns the first n words in the text file. B A procedure isFound, which takes a word and a text file as input and returns true if the word appears in the text file C A procedure textMatch, which takes two text files as input and returns true if the two text files are identical. D A procedure sameSize, which takes two text files as input and returns true if the two text files contain the same number of words.

the correct answer is B A.Incorrect. Obtaining part of a text file is not useful when attempting to determine whether a word appears in two text files. B.Correct. Two calls to this procedure can be used to determine if a particular word appears in each of two text files. If both calls return true, then the word appears in both text files. C.Incorrect. Determining whether two text files have the same exact content is not useful when attempting to determine whether a word appears in two text files. D.Incorrect. Determining whether two text files have the same number of words is not useful when attempting to determine whether a word appears in two text files.

type of ticket Regular (ages 13 and up) Child (ages 12 and below) Genral admission cost 8 6 Guided Tour Cost(in dollars) 10 8 A programmer is creating an algorithm to display the cost of a ticket based on the information in the table. The programmer uses the integer variable age for the age of the ticket recipient. The Boolean variable includes Tour is true when the ticket is for a guided tour and is false when the ticket is for general admission. Which of the following code segments correctly displays the cost of a ticket? A cost ←← 6 IF ((age > 12) OR includesTour) { cost ←← cost + 2 } DISPLAY (cost) B.cost ←← 6 IF (age > 12) { cost ←← cost + 2 } IF (includesTour) { cost ←← cost + 2 } DISPLAY (cost) C cost ←← 6 IF (age > 12) { IF (includesTour) { cost ←← cost + 2 } } DISPLAY (cost) D cost ←← 6 IF (age > 12) { cost ←← cost + 2 } ELSE { IF (includesTour) { cost ←← cost + 2 } } DISPLAY (cost)

the correct answer is B A.Incorrect. This code segment initially sets cost to 6, then increases cost by 2 for people who are going on a guided tour or whose age is greater than 12. As the cost is only increased once, it is not properly set for people who are both older than 12 and going on a guided tour. B.Correct. This code segment initially sets cost to 6 (the cheapest possible ticket price), then increases cost by 2 for people whose age is greater than 12. Regardless of the person's age, cost is increased by 2 for people going on a guided tour. C.Incorrect. This code segment initially sets cost to 6, then increases cost by 2 for people who are going on a guided tour and whose age is greater than 12. As a result, regular guided tour tickets are set to 8, when they should be set to 10. In addition, regular general admission tickets and child guided tour tickets are set to 6 when they should be set to 8. D.Incorrect. This code segment initially sets cost to 6, then increases cost by 2 for people who are either going on a guided tour or whose age is greater than 12. Because of the ELSE statement, the cost is not properly set for people who are both older than 12 and going on a guided tour.

Let n be an integer value. Which of the following expressions evaluates to true if and only if n is a two-digit integer (i.e., in the range from 10 to 99, inclusive)? A.n = (n MOD 100) B.(n ≥ 10) AND (n < 100) C.(n < 10) AND (n ≥ 100) D.(n > 10) AND (n < 99)

the correct answer is B A.Incorrect. This expression evaluates to true for all values of n from 0 to 99, inclusive. B.Correct. This expression evaluates to true if and only if the integer n is greater than or equal to 10 and strictly less than 100. C.Incorrect. This expression evaluates to false for all values of n, since n cannot be both less than 10 and greater than or equal to 100. D.Incorrect. This expression incorrectly evaluates to false when n is equal to 10 and when n is equal to 99.

Which of the following could be used as a replacement for <MISSING STATEMENT> so the code segment works as intended? in the google docs

the correct answer is B A is nor correct because Incorrect. This code segment produces a one-third chance of score being set to each of the three values. B is correct because Correct. The code segment sets the score to 10 25% of the time, to 5 25% of the time, and to -1 the remaining 50% of the time. C is not correct because Incorrect. This code segment produces a one-sixth chance of score being set to 10 or 5 and a two-thirds chance of score being set to -1. D is not correct because Incorrect. This code segment produces a one-eighth chance of score being set to 10 or 5 and a three-quarters chance of score being set to -1.

A program contains the following procedures for string manipulation. Which of the following expressions can be used to generate the string happy ?

the correct answer is B A.This option is incorrect. This expression returns the string huppy. B.This option is correct. This expression concatenates the first two letters of harp with the last three letters of puppy, resulting in happy C .This option is incorrect. This expression returns the string .hapy D.This option is incorrect. This expression returns the string .arpy

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. Consider the procedure MoveAndTurn below.

the correct answer is C

A store uses binary numbers to assign a unique binary sequence to each item in its inventory. What is the minimum number of bits required for each binary sequence if the store has between 75 and 100 items in its inventory? A 5 B 6 C 7 D 8

the correct answer is C A.Incorrect. Using 5 bits will only allow for up to 32 sequences because 25=3225=32. B.Incorrect. Using 6 bits will only allow for up to 64 sequences because 26=6426=64. C.Correct. Using 6 bits will only allow for up to 64 sequences because 26=6426=64. Using 7 bits will allow for up to 128 sequences because 27=12827=128. Therefore, a minimum of 7 bits are needed. D.Incorrect. Using 8 bits will allow for up to 256 sequences because 28=25628=256. However, a unique bit sequence can be assigned using only 7 bits because 27=12827=128.

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 A procedure that returns the quotient when dividing one value by another B A procedure that returns the sum when adding one value to another C A procedure that returns the sum of the values in the file D A procedure that returns true if the file contains any duplicate values and returns false otherwise

the correct answer is C A.Incorrect. While it is necessary to perform a division when calculating an average, division can be accomplished using the / operator instead of a procedure. B.Incorrect. While it is necessary to perform addition when calculating an average, addition can be accomplished using the + operator instead of a procedure. C.Correct. The sum of the values in the file can be divided by the number of values in the file (10,000) to compute the desired average. D.Incorrect. Determining whether the file contains duplicate values is not useful for computing the average.

Which of the following can be used to replace missing code so that the simulation works as intended? A

the correct answer is D

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.

the correct answer is D A.This option is incorrect. The procedure always returns false B.This option is incorrect. The procedure always returns false C.This option is incorrect. The procedure always returns false D.This option is correct. The expression always evaluates to because it is not possible for the variable to be equal to both and . Therefore, the procedure will alwaysreturn .look at college board for more information

Which of the following describes the possible values of ans as a result of executing the code segment? A Any integer value from 1 to 8, inclusive B Any integer value from 1 to 16, inclusive C Any integer value from 4 to 8, inclusive D Any integer value from 7 to 16, inclusive

the correct answer is D A.Incorrect. The possible values of ans are between the sum of the least possible results of the RANDOM calls and the sum of the greatest possible results of the RANDOM calls, not the least and greatest parameters used in the RANDOM calls. B.Incorrect. While the greatest possible value of ans is 16, the least possible value is 7, not 1. C.ncorrect. The possible values of ans are between the sum of the least possible results of the RANDOM calls and the sum of the greatest possible results of the RANDOM calls, not the least and greatest possible results of the last RANDOM call. D.Correct. The first call to RANDOM returns a random integer from 1 to 3, inclusive. The second call to RANDOM returns a random integer from 2 to 5, inclusive. The third call to RANDOM returns a random integer from 4 to 8, inclusive. Therefore, the least possible sum is 1 + 2 + 4, or 7, and the greatest possible sum is 3 + 5 + 8, or 16.

Consider a game in which a player flips a fair coin three times. If all three coin flips have the same result (either all heads or all tails) the player wins. Otherwise, the player loses. Which of the following code segments best simulates the behavior of the game?( the google doc)

the correct answer is D A is not correct because Incorrect. In this code segment, the variable flip is assigned one of four values: 0, 1, 2, or 3. The player wins approximately three out of every four times (when flip is not 3). B is not correct because Incorrect. In this code segment, the variable flip is assigned one of four values: 0, 1, 2, or 3. The player wins approximately two out of every four times (when flip is 0 or 3). c is not correct because Incorrect. In this code segment, three coin flips are simulated, where one result is represented by 1 and the other result is represented by 0. The player only wins when the sum of these is 3. However, the player should also win when the sum is 0. D is correct because Correct. In this code segment, three coin flips are simulated, where one result is represented by 1 and the other result is represented by 0. The player wins when the sum of these is 0 or 3, indicating all heads or all tails.

1.D 0/1 MC point In which of the following situations would it be most appropriate to choose lossy compression over lossless compression? A Storing digital photographs to be printed and displayed in a large format in an art gallery B Storing a formatted text document to be restored to its original version for a print publication C Storing music files on a smartphone in order to maximize the number of songs that can be stored D.Storing a video file on an external device in order to preserve the highest possible video quality

the correct answer is c AIncorrect. In situations where quality is maximally important, lossless compression algorithms are typically chosen. B.Incorrect. In situations where the ability to reconstruct an original is maximally important, lossless compression algorithms are typically chosen. C.Correct. In situations where minimizing data size or transmission time is maximally important, lossy compression algorithms are typically chosen. D.Incorrect. In situations where quality is maximally important, lossless compression algorithms are typically chosen.

A program developed for a Web store represents customer account balances using a format that approximates real numbers. While testing the program, a software developer discovers that some values appear to be mathematically imprecise. Which of the following is the most likely cause of the imprecision? A The account balances are represented using a fixed number of bits, resulting in overflow errors. B The account balances are represented using a fixed number of bits, resulting in round-off errors. C The account balances are represented using an unlimited number of bits, resulting in overflow errors. D The account balances are represented using an unlimited number of bits, resulting in round-off errors.

the correct answer was B A.Incorrect. An overflow occurs when a value exceeds the maximum representable value. This type of error does not typically lead to imprecision of values. B.Correct. The fixed number of bits used to represent real numbers limits the range of these values; this limitation can result in round-off errors. Round-off errors typically result in imprecise values or results. C.Incorrect. Programming languages typically represent numbers with a fixed number of bits. The use of a fixed number of bits can lead to overflow or round-off errors. D.Incorrect. Programming languages typically represent numbers with a fixed number of bits. The use of a fixed number of bits can lead to overflow or round-off errors.

A computer program uses 4 bits to represent nonnegative integers. Which of the following statements describe a possible result when the program uses this number representation? I. The operation 4+8 will result in an overflow error. II. The operation 7+10will result in an overflow error. III. The operation12+3 will result in an overflow error. A I only B II only C II and III only D I, II, and III

the correct answer was B A.This option is incorrect. The operation does not produce a result large enough to cause an overflow error. B.This option is correct. With a 4-bit integer representation, values can be represented, which allows for the values between to , inclusive. If an operation results in a value greater than , an overflow error will occur. Of the operations given in the options, only gives a result larger than . C.This option is incorrect. The operation causes an overflow error, but does not produce a result large enough to cause an overflow error. D.This option is incorrect. The operation causes an overflow error, but the operations and do not produce results large enough to cause an overflow error.

Directions: For the question or incomplete statement below, two of the suggested answers are correct. For this question, you must select both correct choices to earn credit. No partial credit will be earned if only one correct choice is selected. Select the two that are best in each case. Which of the following can be represented by a single binary digit? A The position of the minute hand of a clock B The remainder when dividing a whole number by 2 C The value of a Boolean variable D The volume of a car radio

the correct answer was B and C A.This option is incorrect. The position of a minute hand on a clock can have many possible values. Binary digits can only store two possible values: 0 or 1. B.This option is correct. When dividing a whole number (0, 1, 2, 3, ...) by 2, the remainder will always be 0 or 1. A binary digit, by its definition, stores 0 or 1. C.This option is correct. The value of a Boolean variable is either "true" or "false." These two possible values can be represented by the binary digits 0 or 1. D.This option is incorrect. The volume of a car radio can have many possible values between the lowest possible setting and the highestpossible setting. Binary digits can only store two possible values: 0 or 1.

A programmer is developing software for a social media platform. The programmer is planning to use compression when users send attachments to other users. Which of the following is a true statement about the use of compression? A Lossless compression of video files will generally save more space than lossy compression of video files. B Lossless compression of an image file will generally result in a file that is equal in size to the original file. C Lossy compression of an image file generally provides a greater reduction in transmission time than lossless compression does. D Sound clips compressed with lossy compression for storage on the platform can be restored to their original quality when they are played.

the correct answer was C A.Incorrect. Lossy data compression algorithms can usually provide a greater reduction in the space required than lossless compression algorithms can. B.Incorrect. Lossless compression usually results in a file that is smaller in size than the original file. C.Correct. Although fewer bits may be stored, information is not necessarily lost when lossy compression is applied to an image. D.Incorrect. Lossy compression algorithms allow only an approximation of the original data to be reconstructed.

An online store uses 6-bit binary sequences to identify each unique item for sale. The store plans to increase the number of items it sells and is considering using 7-bit binary sequences. Which of the following best describes the result of using 7-bit sequences instead of 6-bit sequences? A 2 more items can be uniquely identified. B 10 more items can be uniquely identified. C 2 times as many items can be uniquely identified. D 10 times as many items can be uniquely identified.

the correct answer was C A.This option is incorrect. Adding an extra binary digit allows for two times as many items to be identified, not two more. B.This option is incorrect. Adding an extra binary digit allows for two times as many items to be identified, not 10 more. C.This option is correct. Using 6-bit binary sequences allows for 26 or 64 different items to be identified. Using 7-bit binary sequences allows for 27 or 128 different items to be identified. Thus there are two times as many items that can be uniquely identified. D.This option is incorrect. Adding an extra binary digit allows for two times as many items to be identified, not 10 times as many.

Which of the following is NOT a possible value displayed by the program? A "artichoke" B "broccoli" C "carrot" D "daikon"

the correct answer was C A.Incorrect. The string "artichoke" is displayed for values of n that are greater than 100. B.Incorrect. The string "broccoli" is displayed for values of n that are greater than 10 but less than or equal to 100. C.Correct. The string "carrot" can be displayed only when the expression (n > 10) is false and the expression (n > 100) is true. If n is not greater than 10, it cannot be greater than 100, and so "carrot" can never be displayed. D.Incorrect. The string "daikon" is displayed for values of n that are less than or equal to 10.

Which of the following are true statements about the data that can be represented using binary sequences? Binary sequences can be used to represent strings of characters. Binary sequences can be used to represent colors. Binary sequences can be used to represent audio recordings. A I only B I and II only C II and III only D I, II, and III

the correct answer was D A.Incorrect. Statement II is true because colors can be encoded as sequences of bits. Statement III is true because sequences of bits can be used to represent sound. B.Incorrect. Statement III is true because sequences of bits can be used to represent sound. C.Incorrect. Statement I is true because strings of characters can be represented by sequences of bits. D.Correct. All digital data is represented at the lowest level as sequences of bits. Statement I is true because strings of characters can be represented by sequences of bits. Statement II is true because colors can be encoded as sequences of bits. Statement III is true because sequences of bits can be used to represent sound.

Consider the following spinner, which is used to determine how pieces are to be moved on a game board. The region labeled "Move 1 space" is six times as large as each of the other two regions. Which of the following code segments can be used to simulate the behavior of the spinner? look at the google doc

the correct answer was D A.Incorrect. This code segment simulates a spinner in which there is a 4646 chance of "Lose a turn", a 1616 chance of "Move 2 spaces", and a 1616 chance of "Move 1 space". However, the given spinner has a 6868 chance of "Move 1 space", a 1818 chance of "Move 2 spaces", and a 1818 chance of "Lose a turn". B.Incorrect. This code segment simulates a spinner in which there is a 1616 chance of "Lose a turn", a 1616 chance of "Move 2 spaces", and a 4646 chance of "Move 1 space". However, the given spinner has a 6868 chance of "Move 1 space", a 1818 chance of "Move 2 spaces", and a 1818 chance of "Lose a turn". C.Incorrect. This code segment simulates a spinner in which there is a 6868 chance of "Lose a turn", a 1818 chance of "Move 2 spaces", and a 1818 chance of "Move 1 space". However, the given spinner has a 6868 chance of "Move 1 space", a 1818 chance of "Move 2 spaces", and a 1818 chance of "Lose a turn". D.Correct. For this spinner, there is a 1818 chance of "Lose a turn", a 1818 chance of "Move 2 spaces", and a 6868 chance of "Move 1 space". The variable spin is set to a random value between 1 and 8. If spin is 1 (which occurs 1818 of the time), the code segment prints "Lose a turn". If spin is 2 (which occurs 1818 of the time), the code segment prints "Move 2 spaces". The remaining 6868 of the time, the code segment prints "Move 1 space". look at AP question 28

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.

the correct is C AIncorrect. Knowing whether a negative value appears does not give the student enough information to determine the locations of the negative values. The locations are needed so that the student knows which values to change to 0. B.Incorrect. Knowing the total number of negative values does not give the student enough information to determine the locations of the negative values. The locations are needed so that the student knows which values to change to 0. C.Correct. Using this procedure would allow the student to identify the location where a negative value occurs, and then change that value to 0. This process can continue with repeated calls to the procedure until there are no more negative values. D.Incorrect. Knowing the minimum value (which could be negative) does not give the student enough information to determine the locations of the negative values. The locations are needed so that the student knows which values to change to 0.

A numeric test score is to be converted to a letter grade of A, B, or C according to the following rules: A score greater than 90 is considered an A; a score between 80 and 90, inclusive, is considered a B; and any other score is considered a C. Which of the following code segments will assign the correct letter grade to grade based on the value of the variable score ? A II only B I and II only C I and III only D II and III only

this is a D A.Incorrect. Code segment III works correctly. Code segment III assigns "C" when the numeric score is less than 80, or "B" if the numeric score is not less than 80 but is less than or equal to 90, or "A" otherwise. B.Incorrect. Code segment I does not work correctly because it is not possible for "C" to be the value of grade at the end of the code segment. Code segment III also works correctly. Code segment III assigns "C" when the numeric score is less than 80, or "B" if the numeric score is not less than 80 but is less than or equal to 90, or "A" otherwise. C.Incorrect. Code segment I does not work correctly because it is not possible for "C" to be the value of grade at the end of the code segment. Code segment II also works correctly. Code segment II correctly assigns "A" when the numeric score is greater than 90, or "B" if the numeric score is not greater than 90 but is greater than or equal to 80, or "C" otherwise. D.Correct. Code segment I does not work correctly because it is not possible for "C" to be the value of grade at the end of the code segment. Code segment II correctly assigns "A" when the numeric score is greater than 90, or "B" if the numeric score is not greater than 90 but is greater than or equal to 80, or "C" otherwise. Code segment III assigns "C" when the numeric score is less than 80, or "B" if the numeric score is not less than 80 but is less than or equal to 90, or "A" otherwise.


Related study sets

Patho: Cardiovascular Disorders Quiz 7

View Set

Psychology Midterm Study Guide Chapter 4

View Set

practice questions for pharm test #5

View Set

ASTRO 7N Unit 1 Part 1: Gravity Lesson

View Set

Automotive Service Pollution Prevention Final Exam

View Set

MGMT 456 Ch. 14 Comp of Special Groups

View Set