24
AP Computer Science Principles Marking Period 2 Quarterly Exam Bank January 2017 Multiple Choice: 15 problems @ 2 points each. Open-ended: 2 problems @ 10 points each. Total: 50 points. Multiple choice: 29, choose 15. 1. Which of the following is true about pivot tables? a) A well-made pivot table is more compact and easier to read than the raw data. b) A pivot table of survey data can list different numbers that describe responses, including count and average. c) A pivot table can be used to make a visualization. d) All of the above. 2. Here is an example of a word cloud: Word clouds use letter size to show how often different words appear in a text; for example the word cloud above is based on a text where the words “new” and “people” appear very often. Word clouds that look nice are difficult to make, and were not often seen until powerful graphics software became common. What kind of visualization is computationally easier to make, and could do about the same job as a word cloud? a) A pie chart. b) A line graph.

frankhulsman.comfrankhulsman.com/APCSPFAQ/BankOfExamQuestions.d…  · Web viewWord clouds use letter size to show how often different words appear in a text; ... The Wireless Hotspot

  • Upload
    buidan

  • View
    215

  • Download
    1

Embed Size (px)

Citation preview

AP Computer Science PrinciplesMarking Period 2 Quarterly Exam Bank

January 2017

Multiple Choice: 15 problems @ 2 points each.Open-ended: 2 problems @ 10 points each.Total: 50 points.

Multiple choice: 29, choose 15.

1. Which of the following is true about pivot tables?

a) A well-made pivot table is more compact and easier to read than the raw data.b) A pivot table of survey data can list different numbers that describe responses,

including count and average.c) A pivot table can be used to make a visualization.d) All of the above.

2. Here is an example of a word cloud:

Word clouds use letter size to show how often different words appear in a text; for example the word cloud above is based on a text where the words “new” and “people” appear very often.

Word clouds that look nice are difficult to make, and were not often seen until powerful graphics software became common. What kind of visualization is computationally easier to make, and could do about the same job as a word cloud?

a) A pie chart.b) A line graph.c) A histogram.d) A scatter plot.

3. Which of the following is an example of how the digital divide can affect data collection and analysis?

a) Members of an online social network are asked to watch a streaming video about a current event, and answer a survey. People on low-bandwidth networks that cannot handle streaming video would be unlikely to respond.

b) When collecting survey data, responders might use different phrases for essentially the same answer, for example they might list their favorite activity as “reading books” or “reading novels.”

c) If asked what time a certain event happened, responders from around the world will give an answer in their own local time, which can vary because of time zones.

d) People often respond to surveys with answers that they think the questioner wants to hear, instead of more accurate answers.

4. Below is a Google Trends graph showing search trends for the terms “AP Exam” and “SAT Test” over the year 2016.

We can use this data to make predictions for 2017. Which is the best prediction?

a) In 2017, more students will take the SAT than all AP Exams combined.b) Searches for the SAT will relatively steady over the year; searches for the

AP Exam will concentrate around April and May.c) Over the course of 2017, searches for the SAT will increase significantly.d) Study patterns for the two exams will be different; many people will “cram” for

the AP Exams, but study for the SAT over a longer time period.

5. Consider the code segment below,

For the drawSquare() function, the header is on Line __________ and the call is on Line _____________

a) 1, 2b) 2, 7c) 1, 7d) 7, 1

6. Which of the following is the most accurate statement about the difference between natural human languages and programming languages?

a) You can implement an algorithm in a programming language, but not a human language.

b) Human languages are more formal than programming languages.c) Human languages are newer than programming languages.d) Human languages have a larger “vocabulary,” or set of different words,

than programming languages.

7. This problem is about different algorithms carried out of a row of numbered cards on a table. Each card has a number, there is an even number of cards, and they are in no special order. Which of the following algorithms is most likely to involve selection AND iteration?

a) Compare the first two cards. If the one on the left is greater, switch them.b) Swap the positions of each pair of cards. For example, swap cards 0 and 1, swap

cards 2 and 3, and so on for all pairs.c) Look over all the cards to find the smallest one, and move it to the leftmost

position.d) Find the middle card and move it to the leftmost position.

8. Using the standards of data visualizations from class, which of the following is the best visualization? Consider factors including which one communicates the data most clearly, which one has a format that makes sense for its data, and which one is least deceptive.

a) b)

c) d)

9. This image was created using Turtle Graphics in Code Studio:

Start Finish

In the image on the right, the line segments are 50 pixels long.

Which of the following code segments will generate this image?

a) move(50, 50);

b) move(50, 0);move(0, 50);

c) moveForward(50);turnRight(90);moveForward(50);turnRight(90);

d) moveForward(50);turnRight(90);moveForward(50);turnLeft(90);

10. Suppose that in 1970, a certain microchip had 2,000 transistors on it. According to Moore’s Law, which is the best estimate of the number of transistors on a chip of the same size and cost in 1980?

a) 1,000b) 4,000c) 60,000d) 2,000,000

11. Consider the JavaScript code segment,

Which of the following is the most likely image created by this segment?

a) b)

c) d)

12. Consider the JavaScript code segment,

This draws the image:

As you know, if you run the Code Studio code interpreter at a slow speed, it will highlight each line in the order it is executed. If you wrote down each line number in the order it is executed, what would be the sequence of lines for this code segment?

a) 1, 2, 3, 4, 5, 6, 7, 8, 5, 6, 7, 8, 9b) 1, 2, 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 3c) 1, 2, 3, 4, 5, 6, 7, 8, 9d) 1, 2, 4, 5, 6, 7, 8, 9, 3

13. Evaluate: 19 MOD 5.

a) 1b) 3c) 3.8d) 4

14. Suppose you are working on a programming project. A friend suggests a built-in function you might want to use. What would be the best way to learn about how to use that function for your project?

a) Read the API for that function.b) Read the source code for that function.c) Read the cipher for that function.d) Read the heuristic for that function.

15. Match the name of the encryption method with the description.

______ For this method, encryption is asymmetric; a secret message can be encrypted using a number that is not private, and decrypted with a number that is private.

______ For this method, the key is a single number. To encrypt a message, each letter is replaced by a letter a fixed interval down the alphabet. For example, A maps to F, B maps to G, and so on.

______ For this method, the key consists of several numbers. To encrypt a message, each letter is replaced by a letter a certain interval down the alphabet. However, these intervals themselves change as you iterate through the message.

a) Caesar cipherVigenere cipherPublic-key encryption

b) Caesar cipherPublic-key encryptionVigenere cipher

c) Vigenere cipherCaesar cipherPublic-key encryption

d) Public-key encryptionCaesar cipherVigenere cipher

16. Which of the following is an example of abstraction?

I. If you are driving a car, you may not know how the engine works, but you can use the steering wheel and pedals as an interface to control where the car goes.

II. A team of programmers each writes one function for a large programming project. Each does not know in detail how the other functions work, but they can still integrate each function into a working project.

III. A delivery service has an app to determine the shortest route to reach 100 destinations. It is too complicated to calculate the absolute best route, so the app uses an approximate solution that is reasonably efficient.

a) I and IIb) II and IIIc) I and IIId) I, II, and III

17. A friend is writing a program that draws a picture using Turtle Graphics. The picture will include small, medium, and large triangles, so they decide to write three functions that look like this:

function smallTriangle() { for (var i = 0; i < 3; i++) {

moveForward(10); turnRight(120); }}

function mediumTriangle() { for (var i = 0; i < 3; i++) { moveForward(50); turnRight(120); }}

function largeTriangle() { for (var i = 0; i < 3; i++) { moveForward(100); turnRight(120); }}

These functions can be called at different places in the program to draw triangles at different locations in the picture. Note that the three functions are similar; the only difference is that the value plugged into moveForward().

Keeping in mind the principles of abstraction and top-down design, what is the best piece of advice you can offer your friend?

a) They should write some more functions, for example tinyTriangle() and extraLargeTriangle() in case they want a greater variety of triangle sizes.

b) They can replace all three functions with one function that takes a parameter for the side length of the triangle.

c) Functions are confusing for the reader, so they should not be used. Instead, they should simply write a new for loop each time they want to draw a triangle.

d) No changes are needed; this is the best possible way to write this program.

18. Suppose that you currently use a Gmail account for your personal email address. Gmail collects data from its users’ emails. You are considering switching to NoSnoopMail™, which does not collect any data from users. Which of the following is NOT a likely difference between Gmail and NoSnoopMail?

a) NoSnoopMail may have fewer useful features than Gmail, for example the email search tool may be less accurate or there may be less storage space.

b) Gmail displays ads for products based on words found in your email; NoSnoopMail does not display ads.

c) Gmail is free; NoSnoopMail charges users a monthly fee.d) You will not be able to send messages to Gmail addresses.

19. Which of the following is NOT a computationally hard problem?

a) The traveling salesperson problem: given a map of cities, find the shortest route that visits each city once.

b) Factoring a number into prime factors.c) Finding the MOD of two numbers.d) The Wireless Hotspot (vertex cover) problem: given a map of houses, find

locations for the lowest number of WiFi hotspots that will reach all the houses.

20. _________ is a heuristic method of breaking encryption by comparing how often letters appear in the cipher text to how often they appear in typical English writing.

a) Frequency analysis.b) Brute force method.c) Modulo arithmetic.d) Letter abstraction.

21. Consider the procedure mystery(num, list):

PROCEDURE mystery (num, list){ FOR EACH item IN list { if (list [item] MOD num == 0) { DISPLAY list[item] + “ “ REMOVE list[item] } }} If list myList contains the following data: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], what will be displayed by mystery (3, myList)? (A) 10 8 7 5 4 2 1(B) 9 6 3 0(C) 10 8 7 5 4 2 1 0(D) 9 6 3

22. The Hailstone Sequence, which includes numbers that rise and fall like hailstones in a cloud, are defined by the 3n + 1 conjecture, which states that if you follow the below algorithm, the series will always end with 1.

Consider the algorithm below:

Do until n is 1: If n is even, divide it by 2. Otherwise, multiply n by 3 and add 1.

Which of the following program segments correctly implements the algorithm?

(A)

(B)

(C)

(D)

23. What are the two aspects of efficiency?

(A) memory usage and length of code(B) execution time and length of code(C) wall clock time and CPU time (D) execution tine and memory usage

24. A crime investigator is accessing an online database of crimes within a certain radius of the city center. The database e contains the following information: Date of crimeName of offendersNeighborhood of crime

The investigator is looking for other crimes that occurred in a certain area on a certain date. Which of the following algorithms can he use to find all crimes that occurred in a certain neighborhood on a certain day? I. Make a new list by filtering the data so only the crimes from a certain neighborhood are on the list. Perform multiple binary searches to find all crimes that occurred in a certain neighborhood on a certain day, adding each new occurrence to a final list.II. Make a new list by filtering the data so only the crimes from a certain neighborhood are on the list. Perform multiple linear searches to find all crimes that occurred on the given day, adding each new occurrence to a final list. (A) Algorithm I only(B) Algorithm II only(C) Both Algorithms I and Algorithm II(D) Neither Algorithm I nor Algorithm II

25. The question below uses a simple programming language, with the following instructions. Product ← 500REPEAT 1000 TIMES{product ← product * product + 1} In some coding languages, the above code will result in an error.Why? (A) The fixed number of bits used to represent real numbers (as floating-point numbers) limits the range of floating-point values and mathematical operations.(B) The multiple levels of abstraction used oversimplified the code.(C) The value of product will always be 0.(D) The fixed number of bits used to represent characters or integers limits the range of integer values and mathematical operations.

26. An online gaming website has a list of users that has been sorted alphabetically by last name. In order to find a certain user, a binary search is performed. As many new members are added to the database, will the number of steps the algorithm will take to solve the problem most likely also increase? Why or why not? (A) Yes, because the new members may not be added alphabetically(B) No, the program is written already, and will take the same number of steps regardless of the size of the database(C) Yes, the number of steps in an algorithm changes proportional to the size of the input(D) No, because the search is binary, so the dataset is split in half with every iteration

27. Consider an algorithm that simulates rolling two number die, Die1 and Die2, with the numbers 1 – 6, and then displays the sum of the two cubes’ values. If the sum is greater than 10, the phrase “You are a Winner!” displays, otherwise, “You have Lost!” displays. Put the steps of the algorithm in order. Select two answers. Step 1: Assign random values between 1 and 6 to Die1.Step 2: If sum is greater than 10, display “You are a Winner!”.Step 3: Display sum.Step 4: If the sum if less than or equal to 10, display “You have Lost!”.Step 5: Assign random values between 1 and 6 to Die2.Step 6: Assign the value of Die1 + Die2 to sum. (A) Step 1, Step 5, Step 6, Step 3, Step 4, Step 2(B) Step 5, Step 1, Step 6, Step 3, Step 2, Step 4(C) Step 5, Step 1, Step 2, Step 4, Step 6, Step 3(D) Step 1, Step 5, Step 3, Step 6, Step 2, Step 4

28 - 29. Consider the following incomplete code segment, with the goal of moving the robot in the grid around the obstacle.

REPEAT 3 TIMES{

REPEAT UNTIL (/* missing code */) { MOVE_FORWARD ( ) } ROTATE_LEFT ( )}

28. Which of the following will correctly replace /* missing code */?

(A) CAN_MOVE (left)(B) NOT CAN_MOVE (left)(C) NOT CAN_MOVE (forward)(D) CAN_MOVE(left) AND NOT CAN_MOVE(forward)

29. Which of the following lines of code would cause an error with the robot?

(A) CAN_MOVE (right)(B) CAN_MOVE (south)(C) CAN_MOVE (forward)(D) CAN_MOVE (left)

Open-ended: 2 problems, 10 points each. (Both exams will use these 2).

1. Programming problem (NOTE: On the test, we would give the students a table of all the JavaScript and Turtle Graphics functions, control statements, etc. they used in Code Studio, with short descriptions. This table will be made soon.)

a) (5 points) Write a function called roundedSquare(side) that uses Turtle Graphics to draw a square of side length side with rounded corners.

- The turning radius of the corners should be 0.1 times the side length; for example, if the side length is 20 the turning radius should be 2.

- Each corner is a quarter-circle, or in other words an arc.- Please use the parameter side as the side length.- For full points, your function should use a for loop.- If the function is called, it should draw a square that looks approximately like

this:

Write your function below.

function roundedSquare(side) {

}

b) (5 points) On this part, you will use the roundedSquare(side) function from the previous part. Even if you are not certain if your code works, you can use it assuming it works correctly on this problem.

For this part, write a program that uses your function roundedSquare(side) to draw a pattern that looks like this. Make each square 100 x 100 pixels, with different colors as shown below.

Code:

2. Open-ended essay problem:

a) (5 points) Suppose you are the Chief Data Manager for a financial startup. Your company wants to provide a way for customers to save money in an account, spend money, and track their spending. They should be able to log in to their account using a website or mobile app, and securely send sensitive financial information. Below, discuss how you will keep customers’ data secure, while still giving them easy access to it. Your answer should consider how to defend from BOTH electronic attacks and social engineering attacks.

b) (5 points) Your company has access to a great deal of data from customers, including when and where customers spend money, what they spend it on, where they live, and their income. Your company is considering ways they can use the data. Some ideas include:

i) Collect customers’ data, but only share it with them. A customer can use their data to track their finances.

ii) Collect customers’ data, average it all together, and sell the aggregate data to advertisers. Advertisers will know average data on your typical customer, but not the exact data for each person.

iii) Collect customers’ data, and sell each individual’s data to advertisers. Advertisers will have financial records for each individual customer.

Decide on the best policy for your company, and explain why you chose that one. What are the advantages of the policy you chose, and why is it better than the other ones? For the option you pick, you also consider how you communicate your policy to your customers – do you bury your policy in the fine print of a User License Agreement, or display your policy prominently on your website?

There is no “right” or “wrong” answer, as long as you back up your choice with good arguments.