Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 13 pages
Exam (elaborations)

3.1-3.10 AP-Style MC Practice & Quizzes Questions and Answers

Document preview thumbnail
Preview 2 out of 13 pages

3.1-3.10 AP-Style MC Practice & Quizzes Questions and Answers Which of the following can be represented by a single binary digit? a)The temperature setting of a thermostat. b)A darkness setting on a toaster. c)The speed limit on a major highway. d)The direction of travel for an elevator. d)The direction of travel for an elevator. -This is correct. The direction of an elevator can take only 2 values (up/down), therefore a single binary digit would be sufficient to represent this information (e.g. using a 1 to represent up and a 0 to represent down). Which of the following questions cannot be easily answered using a binary set of answers? a)Which is the best song new song from last year? b)Would you like to go to the store? c)Do you prefer Mac or PC computers? d)When you write with a pen or pencil, which hand do you use? a)Which is the best song new song from last year? -This is correct. There are many possible answers to this question, as in one year many thousands of songs are released. A binary set of answers only allows for 2 possibilities, represented by a 1 or a 0. Which of the following statements about 32-bit binary values is NOT true? a)All real numbers within a finite interval can be expressed by a 32-bit integer representation. b)All whole numbers within a finite interval can be expressed by a 32-bit floating-point representation. c)All real numbers within a finite interval can be approximately expressed by a 32-bit floating-point representation. d)All whole numbers within a finite interval can be expressed by a 32-bit integer representation. a) All real numbers within a finite interval can be expressed by a 32-bit integer representation. -This is correct. This is a false statement. The term "real numbers" refers to all numbers, including irrational numbers like π and 2 as well as infinitely repeating decimals. Every finite interval contains infinitely many of these real numbers, therefore it is not possible to represent them all using a finite amount of digits. What is the binary equivalent to the decimal number of 78? a)1001100 b)1100110 c)1001110 d) c)1001110 -This is correct. The value of 78 can be found using the following algorithm: Find the highest power of 2 which is smaller than or equal to 78: this is 26 = 64. Subtract this from 78: 78 − 64 = 14. Repeat this procedure until 0 is reached: the largest power of 2 smaller than or equal to 14 is 23 = 8 and 14 − 8 = 6. The largest power of 2 which is smaller than or equal to 6 is 22 = 4 and 6 − 4 = 2. The largest power of 2 which is smaller than or equal to 2 is 21 = 2 and 2 − 2 = 0. Having completed this algorithm we can see that 78 = 21 + 22 + 23 + 26. As the nth column from the right in a binary number represents 2n, this tells us that the 2nd, 3rd, 4th and 7th digits from the right will be 1's and the other digits will be 0's giving us the binary number 1001110. Which of the following decimal values, when converted to binary (ignore leading zeros) have exactly 3 zeros in them? Select two answers. a)40 b)50 c)20 d)30 b)50 -This is correct. The binary representation of 50 is 110010, so this has exactly 3 zeros in it. & c)20 -This is correct. The binary representation of 20 is 10100, so this has exactly 3 zeros in it. ASCII is a common format for the representation of characters in writing code. How many characters can be represented in the standard ASCII encoding? a)2^8 b)2^16 c)2^15 d)2^7 d)27 -This is correct. The standard ASCII encoding developed in the 1960s uses 7 binary digits to represent each character, giving a total of 27 = 128 different possible characters. Using the table given below, determine the ASCII to binary code conversion for the word science. a) b) c) d) b) -This is correct. The characters making up science are s, c, i, e and n. By finding each of these characters in the table and writing the 4 digits for the row it is in followed by the 4 digits for the column it is in we can represent each of these as a binary ASCII encoding: s = , c = , i = , e = , n = ,. Putting these characters one after another to make the word science we get the encoding in this answer choice. The following steps can be used to encode a string of text using Base64 encoding: 1. Convert the ASCII characters to their corresponding decimal value 2. Convert the decimal values to their 8-bit equivalents 3. Join all of the bits together to form one continuous string 4. Split the combined string into groups of 6 bits 5. From left to right, convert each group of 6 bits to their corresponding decimal values 6. Convert those decimal values back to the corresponding Base64 values If I started with the three ASCII characters "CSP", how many Base64 values will I be left with at the end? a)6 b)2 c)24 d)4 d)4 -This is correct. The three ASCII characters will each be represented by 8 bits when converted into binary. This means there will be 3 8 = 24 bits representing the message. When this is split into groups of 6 bits, there will be in total 24 ÷ 6 = 4 groups. Each of these groups converts into one Base64 value, so the encoded message will consist of 4 values. If our list called List is populated as [0, 1, 2, 3, 4], what happens if our code tries to access List [5] per the rules of the AP Computer Science Principles Reference Guide? a)The output will be 4 b)The program gives us the number 5 because it comes after 4 c)The output will be 1 d)An error message will be produced a)The output will be 4 -This is correct. The Pseudocode used in the AP CSP course indexes items on the list according to their position, beginning from 1. Hence in this list, the item at index 1 is 0, the item at index 2 is 1 etc. Therefore when the code is run with the statement List [5], the item in the 5th position of the list will be accessed. This is the number 4. The county clerk's office is writing a program to search their database for citizen records based on information about that citizen such as first name, last name, age, etc. Given below is a segment of pseudocode that should find the record of every citizen over the age of 50 in the county. The code makes use of the functions GetAgeOf and GetNameOf, which are used to retrieve the age and name of a citizen from a record which is inputted. For each person in citzlist { age=GetAgeOf(person) name=GetNameOf(person) IF(age 50) { DISPLAY(name) } There is a mistake in this pseudocode. Which of the following is the correct pseudocode to find the records of all citizens over the age of 50. a)FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age 51) { DISPLAY(name) } } b)FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age = 50) { d)FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age 50) { DISPLAY(name) } } -This is correct. This code uses the condition (age 50) in the IF block, meaning the code in this block is only run if the value of the variable age is greater than 50. As this variable is set to the age of the next person on the list each time the loop iterates, this block will only run for a person over 50. The code in the IF block displays the variable name, which is set to the name of the person on the list currently being dealt with. Therefore this code correctly displays the name of each person on the list over 50. Daija is creating a budget, and evaluating his purchases over the last month. Consider the following code segment which attempts to find the sum of all purchases made in the last month, stored in (purchaseList). n ← 1 sum ← 0 REPEAT UNTIL (missing code) { sum ← sum + purchaseList[n] n ← n + 1 } What code can replace missing code to assign the total of all values in (purchaseList) to sum? I. n = LENGTH (purchaseList) II. n ≥ LENGTH (purchaseList) III. n LENGTH (purchaseList) a)I, II, and III b)III only c)II and III d)II only b)III only -This is correct. The loop needs to exit after the last item in purchaseList has been processed. The variable n starts with a value of 1, and the last item of the list will have a position number equal to LENGTH (purchaseList). The item at position n is added to the list each run of the loop before the value of n is increased by 1. Therefore the last time the loop runs we want n to be equal to LENGTH (purchaseList), but at the end of this run of the loop, increase to greater than this. Therefore the repeat until condition should be that n is greater than LENGTH (purchaseList). This is expressed as n LENGTH (purchaseList). If one of the other two conditions is used, the loop will exit when n is equal to equal to LENGTH (purchaseList). Therefore the last item on the list at position n will not be added to the list. The code below and accompanying table will output a number which represents which of the following: a)The average of grades above 79. b)The code has errors, none of these will be displayed. c)The total number of grades above 79. d)The average of the 13 grades. a)The average of grades above 79. -This is correct. The repeat loop checks the value of the item at position index# on Grades. If it is smaller than 80 then it is deleted. The value of index# is not changed if this is the case, as the next item on Grades will be shifted into the position of index# by this deletion. If the value is larger than 80, then it is added to the variable total, and the value of index# is incremented by 1. As the repeat loop is run the same number of times as the number of items on the list, then each item on the list will be processed in this way. At the end, the list will only contain the grades which are not smaller than 80, and each of these will have been added to total. As all the grades are integers, the grades which are not smaller than 80 are equivalent to grades which are larger than 79. The value of total is then divided by the current length of Grades to give the average of these numbers. A teacher uses the following program to adjust student grades on an assignment by adding 5 points to each student's original grade. However, if adding 5 points to a student's original grade causes the grade to exceed 100 points, the student will receive the maximum possible score of 100 points. The students' original grades are stored in the list gradeList, which is indexed from 1 to n. i ← 1 REPEAT n TIMES { i ← i + 1 } The teacher has the following procedures available. min (a, b): Returns the lesser of the two values a and b max (a, b): Returns the greater of the two values a and b Which of the following code segments can replace so that the program works as intended? Select two answers. a)gradeList [i] ← min (gradeList[i] + 5, 100) b)gradeList [i] ← gradeList[i] + 5 IF (gradeList [i] 100) { gradeList [i] ← 100 } c)gradeList [i] ← max (gradeList[i] + 5, 100) d)gradeList [i] ← gradeList[i] + 5 IF a)gradeList [i] ← min (gradeList[i] + 5, 100) -This is correct. The statement min (gradeList[i] + 5, 100) returns gradeList[i] + 5 if this is smaller than 100, and 100 otherwise since it returns the minimum of the two expressions. Therefore with this code the program will set each grade 5 points higher if that does not give a result greater than 100, and set it to 100 otherwise. b)gradeList [i] ← gradeList[i] + 5 IF (gradeList [i] 100) { gradeList [i] ← 100 } -This is correct. For each grade, this code will initially increase its value by 5, before using an IF statement with a condition checking if the modified grade is greater than 100. If it is, then the code in the IF block will run, setting the value of the grade to 100. Therefore with this code the program will set each grade 5 points higher if that does not give a result greater than 100, and set it to 100 otherwise. Sometimes we care about the order of a list, and need to reorder the items according to a condition (alphabetical, numerical, etc). An algorithm finds the minimum value in the list and swaps it with the value in the first position, then repeats these steps for the remainder of the list, swapping with the second position, then the third position and so forth. What type of sorting is this? a)insertion b)bubble c)shuffle d)selection d)selection -This is correct. This algorithm is commonly called a selection sort as each time the minimum value is "selected" from the remaining list and moved to the top.

Content preview

3.1-3.10 AP-Style MC Practice & Quizzes
Questions and Answers
Which of the following can be represented by a single binary digit?

a)The temperature setting of a thermostat.
b)A darkness setting on a toaster.
c)The speed limit on a major highway.
d)The direction of travel for an elevator. - answer d)The direction of travel for an
elevator.

-This is correct. The direction of an elevator can take only 2 values (up/down), therefore
a single binary digit would be sufficient to represent this information (e.g. using a 1 to
represent up and a 0 to represent down).

Which of the following questions cannot be easily answered using a binary set of
answers?

a)Which is the best song new song from last year?
b)Would you like to go to the store?
c)Do you prefer Mac or PC computers?
d)When you write with a pen or pencil, which hand do you use? - answer a)Which is
the best song new song from last year?

-This is correct. There are many possible answers to this question, as in one year many
thousands of songs are released. A binary set of answers only allows for 2 possibilities,
represented by a 1 or a 0.

Which of the following statements about 32-bit binary values is NOT true?

a)All real numbers within a finite interval can be expressed by a 32-bit integer
representation.
b)All whole numbers within a finite interval can be expressed by a 32-bit floating-point
representation.
c)All real numbers within a finite interval can be approximately expressed by a 32-bit
floating-point representation.
d)All whole numbers within a finite interval can be expressed by a 32-bit integer
representation. - answer a) All real numbers within a finite interval can be expressed
by a 32-bit integer representation.

-This is correct. This is a false statement. The term "real numbers" refers to all numbers,
including irrational numbers like π and 2 as well as infinitely repeating decimals. Every

, finite interval contains infinitely many of these real numbers, therefore it is not possible
to represent them all using a finite amount of digits.

What is the binary equivalent to the decimal number of 78?

a)1001100
b)1100110
c)1001110
d) - answer c)1001110

-This is correct. The value of 78 can be found using the following algorithm: Find the
highest power of 2 which is smaller than or equal to 78: this is 26 = 64. Subtract this
from 78: 78 − 64 = 14. Repeat this procedure until 0 is reached: the largest power of 2
smaller than or equal to 14 is 23 = 8 and 14 − 8 = 6. The largest power of 2 which is
smaller than or equal to 6 is 22 = 4 and 6 − 4 = 2. The largest power of 2 which is
smaller than or equal to 2 is 21 = 2 and 2 − 2 = 0. Having completed this algorithm we
can see that 78 = 21 + 22 + 23 + 26. As the nth column from the right in a binary
number represents 2n, this tells us that the 2nd, 3rd, 4th and 7th digits from the right will
be 1's and the other digits will be 0's giving us the binary number 1001110.

Which of the following decimal values, when converted to binary (ignore leading zeros)
have exactly 3 zeros in them?

Select two answers.

a)40
b)50
c)20
d)30 - answer b)50

-This is correct. The binary representation of 50 is 110010, so this has exactly 3 zeros in
it.

&

c)20

-This is correct. The binary representation of 20 is 10100, so this has exactly 3 zeros in
it.

ASCII is a common format for the representation of characters in writing code. How
many characters can be represented in the standard ASCII encoding?

a)2^8
b)2^16
c)2^15

Document information

Uploaded on
January 2, 2025
Number of pages
13
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Pogba119
3.9
(14)
Sold
62
Followers
2
Items
5513
Last sold
5 days ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions