AP Computer Science Flashcards

1
Q

Which of the following is a benefit of using a list as a data abstraction in a program?

Lists often allow their size to be easily updated to hold as many data values as needed.

Lists convert all elements to strings so that they can be inspected character-by-character.

Lists prevent duplicate data values from appearing in the list.

Lists are used to store all input data so that there is a running record of all user input.

A

Lists often allow their size to be easily updated to hold as many data values as needed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A programmer has a need to round many numeric values to the nearest integer. Which of the following best explains the benefit of using a list as a data abstraction in this situation?

A

Keeping the numeric values in a list makes it easier to apply the same computation to every data element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Assume that both lists and strings are indexed starting with index 1.

The list wordList has the following contents.

[“abc”, “def”, “ghi”, “jkl”]

Let myWord be the element at index 3 of wordList. Let myChar be the character at index 2 of myWord. What is the value of myChar ?

A

“h”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Consider the following code segment.

The figure present three blocks of code that consist of 3 lines. Line 1: [begin block] yourList ← [begin block] 20, 40, 60, 80 [end block] [end block] Line 2: [begin block] myList ← [begin block] 10, 30, 50, 70, [end block] [end block] Line 3: [begin block] yourList ← myList [end block]
What are the contents of yourList after the code segment is executed?

A

20,40,60,80

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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?

Responses

[]

A

[“guitar”, “drums”, “bass”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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 sum of the values in the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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 findNegative, which returns the row number of the first negative value that appears in the column or -1 if there are no negative values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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 isFound, which takes a word and a text file as input and returns true if the word appears in the text file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The list wordList contains a list of 10 string values. Which of the following is a valid index for the list?

A

4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Consider the following code segment.

The figure presents three blocks of code that consists of 4 lines. Throughout the blocks of code there are nested blocks of code, as follows. Line 1: [Begin Block] result ← 2 [End Block] [Begin Block] Line 2: REPEAT 3 TIMES [Begin Block] Line 3: [Begin Block] result ← result * 5 [End Block] [End Block] [End Block] Line 4: [Begin Block] DISPLAY [Begin Block] result [End Block] [End Block]
Which of the following best describes the behavior of the code segment?

A

The code segment displays the value of
by initializing result to 2 and then multiplying result by 5 a total of three times.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

DineOutHelper is a mobile application that people can use to select a restaurant for a group meal. Each user creates a profile with a unique username and a list of food allergies or dietary restrictions. Each user can then build a contact list of other users of the app.

A user who is organizing a meal with a group selects all the members of the group from the user’s contact list. The application then recommends one or more nearby restaurants based on whether the restaurant can accommodate all of the group members’ allergies and dietary restrictions.

Suppose that Alejandra is using DineOutHelper to organize a meal with Brandon and Cynthia.

Question
Which of the following data are needed for DineOutHelper to recommend a restaurant for the group?

Each group member’s list of food allergies or dietary restrictions
Alejandra’s geographic location
The usernames of the people on Brandon and Cynthia’s contact lists

A

l and ll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

DineOutHelper is a mobile application that people can use to select a restaurant for a group meal. Each user creates a profile with a unique username and a list of food allergies or dietary restrictions. Each user can then build a contact list of other users of the app.

A user who is organizing a meal with a group selects all the members of the group from the user’s contact list. The application then recommends one or more nearby restaurants based on whether the restaurant can accommodate all of the group members’ allergies and dietary restrictions.

Suppose that Alejandra is using DineOutHelper to organize a meal with Brandon and Cynthia.

Question
Which of the following data is not provided by Alejandra but is necessary for DineOutHelper to recommend a restaurant for the group?

Brandon’s contact list
Information about which restaurants Brandon and Cynthia have visited in the past
Information about which food allergies and dietary restrictions can be accommodated at different restaurants near Alejandra

A

ll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

RunRoutr is a fitness tracking application for smartphones that creates suggested running routes so that users can run with each other. Upon downloading the application, each user creates a username, a personal profile, and a contact list of friends who also use the application. The application uses the smartphone’s GPS unit to track a user’s location, running speed, and distance traveled. Users can use the application to review information and statistics about their previous runs.

At the beginning of a run, users indicate the distance they want to run from their current location, and the application suggests a running route. Once a user accepts a suggested route, the application shares the suggested route with other compatible users in the area so that they can run together. Users are considered compatible if they are on each other’s contact lists or if they typically run at similar speeds.

A basic RunRoutr account is free, but it displays advertisements that are targeted to individual users based on data collected by the application. For example, if a user’s running route begins or ends near a particular store, the application may display an advertisement for that store. Users have the ability to pay a monthly fee for a premium account, which removes advertisements from the application.

Question
Adrianna uses RunRoutr to suggest a running route. All compatible users near Adrianna receive a notification that shows her running route. Which of the following data is not obtained using data collected from Adrianna’s smartphone but necessary for RunRoutr to share Adrianna’s running route?

A

The current locations of other RunRoutr users

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

RunRoutr is a fitness tracking application for smartphones that creates suggested running routes so that users can run with each other. Upon downloading the application, each user creates a username, a personal profile, and a contact list of friends who also use the application. The application uses the smartphone’s GPS unit to track a user’s location, running speed, and distance traveled. Users can use the application to review information and statistics about their previous runs.

At the beginning of a run, users indicate the distance they want to run from their current location, and the application suggests a running route. Once a user accepts a suggested route, the application shares the suggested route with other compatible users in the area so that they can run together. Users are considered compatible if they are on each other’s contact lists or if they typically run at similar speeds.

A basic RunRoutr account is free, but it displays advertisements that are targeted to individual users based on data collected by the application. For example, if a user’s running route begins or ends near a particular store, the application may display an advertisement for that store. Users have the ability to pay a monthly fee for a premium account, which removes advertisements from the application.

Question
Which of the following data must be collected from a user’s smartphone in order for RunRoutr to suggest a running route?

A

The user’s geographic position

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly