APCSP U3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

An office building has two floors. A computer program is used to control an elevator that travels between the two floors. Physical sensors are used to set the following Boolean variables. The elevator moves when the door is closed and the elevator is called to the floor that it is not currently on. Which of the following Boolean expressions can be used in a selection statement to cause the elevator to move?

(onFloor1 AND callTo2) OR (onFloor2 AND callTo1)

The program segment below is intended to move a robot in a grid to a gray square. The program segment uses the procedure GoalReached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise. The robot in each grid is represented as a triangle and is initially facing left. The robot can move into a white or gray square but cannot move into a black region. For which of the following grids does the program NOT correctly move the robot to the gray square?

* L shape on the left and grey square in the top left. *

Which of the following school policies is most likely to have a positive impact on the digital divide?

A school provides a laptop or tablet computer to all students enrolled at the school.

Consider the code segment below. If the variables onTime and absent both have the value false, what is displayed as a result of running the code segment?

Better late than never.

There are 32 students standing in a classroom. Two different algorithms are given for finding the average height of the students. Algorithm A Step 1: All students stand. Step 2: A randomly selected student writes his or her height on a card and is seated. Step 3: A randomly selected standing student adds his or her height to the value on the card, records the new value on the card, and is seated. The previous value on the card is erased. Step 4: Repeat step 3 until no students remain standing. Step 5: The sum on the card is divided by 32. The result is given to the teacher. Algorithm B Step 1: All students stand. Step 2: Each student is given a card. Each student writes his or her height on the card. Step 3: Standing students form random pairs at the same time. Each pair adds the numbers written on their cards and writes the result on one student's card; the other student is seated. The previous value on the card is erased. Step 4: Repeat step 3 until one student remains standing. Step 5: The sum on the last student's card is divided by 32. The result is given to the teacher. Which of the following statements is true?

Both Algorithm A and Algorithm B always calculate the correct average.

Which of the following is the most likely data privacy concern of the upgraded system?

Customers' personal information could be compromised if an unauthorized individual gains access to the call session database

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of goats and sheep throughout the text. Consider the programmer's goal of changing all occurrences of "goats" to "sheep" and all occurrences of "sheep" to "goats." The programmer will use the fact that the word "foxes" does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish the programmer's goal?

First, change all occurrences of "goats" to "foxes." Then, change all occurrences of "sheep" to "goats." Last, change all occurrences of "foxes" to "sheep."

To direct a call to the appropriate destination, which of the following input data is needed by the upgraded system that was NOT needed by the original system? I. Audio signal of the customer's voice II. The customer's keypad selection III. The customer's phone number

I only

A summer camp offers a morning session and an afternoon session. The list morningList contains the names of all children attending the morning session, and the list afternoonList contains the names of all children attending the afternoon session. Only children who attend both sessions eat lunch at the camp. The camp director wants to create lunchList, which will contain the names of children attending both sessions. The following code segment is intended to create lunchList, which is initially empty. It uses the procedure IsFound (list, name), which returns true if name is found in list and returns false otherwise. Which of the following could replace <MISSING CODE> so that the code segment works as intended?

IF (IsFound (afternoonList, child)) { APPEND (lunchList, Child) }

In a certain country, a person must be at least 16 years old to drive a car and must be at least 18 years old to vote. The variable age represents the age of a person as an integer. Which of the following expressions evaluates to true if the person is old enough to drive but not old enough to vote, and evaluates to false otherwise? (age ≥ 16) AND (age ≤ 18) (age ≥ 16) AND (NOT(age ≥ 18)) (age < 18) AND (NOT(age < 16)

II and III only

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. Which of the following code segments will move the robot to the gray square?

MoveandTurn [2,1] MoveandTurn [4,3] MoveandTurn [2,0]

The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended. Which of the following changes can be made so that the procedure will work as intended?

Moving the statement in line 5 so that it appears between lines 2 and 3

Consider the following program code. I<0 sum<0 [Repeat until I=4 I<1 sum<sum+1 I<I+1] Display sum

Nothing is displayed; the program results in an infinite loop.

In the following statement, val1, val2, and result are Boolean variables. Which of the following code segments produce the same result as the statement above for all possible values of val1 and val2 ? Select two answers.

Result<False If Val1 [If NOT Val2 Result<True] [If Val1 Val2 Result<False Else Result<True] Else [Result<False]

A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display the number of elements in the list that have a value greater than 100. The algorithm uses the variables count and position. Steps 3 and 4 are missing. Which of the following could be used to replace steps 3 and 4 so that the algorithm works as intended?

Step 3: Increase the value of position by 1. Step 4: Repeat steps 2 and 3 until the value of position is greater than n.

Refer to the information in the quiz instructions to answer this question. Which of the following is most likely to be a benefit of storing the information from each calling session in a database?

The company can analyze the calling session data and thereby make better business decisions

The following grid contains a robot represented as a triangle. The robot is initially facing right. Which of the following code segments can be used to move the robot to the gray square along the path indicated by the arrows?

n<1 Repeat 3 times [Repeat n times move_forward] Rotate_left [Repeat n times move_forward] Rotate right n<n+1

The following code segment is intended to set max equal to the maximum value among the integer variables x, y, and z. The code segment does not work as intended in all cases. Which of the following initial values for x, y, and z can be used to show that the code segment does not work as intended?

x = 3, y = 2, z = 1

Consider the following procedure. Procedure Call:Explanation drawCircle(xPos, yPos, rad): Draws a circle on a coordinate grid with center (xPos, yPos) and radius rad The drawCircle procedure is to be used to draw the following figure on a coordinate grid. Which of the following code segments can be used to draw the figure? Select two answers

x ← 4 y ← 1 r ← 0 REPEAT 3 TIMES { r ← r + 1 y ← y + 1 drawCircle(x, y, r) } x ← 4 y ← 4 r ← 3 REPEAT 3 TIMES { drawCircle(x, y, r) y ← y - 1 r ← r - 1 }


Set pelajaran terkait

Anthropology 1050 Exam 4 Study Guide Chapter 16

View Set

Econ Chapter 9: Economies of Scale and Scope

View Set

Chapter 62 - Care of Patients with Pituitary and Adrenal Gland Problems

View Set

HIST 150 Chapter 15: Reordering the World, 1750-1850

View Set

Principles of Insurance and General Insurance

View Set