Chapter 1 AP Comp Sci

¡Supera tus tareas y exámenes ahora con 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. Variable Description onFloor1 Set to true if the elevator is stopped on floor 1; otherwise set to false onFloor2 Set to true if the elevator is stopped on floor 2; otherwise set to false callTo1 Set to true if the elevator is called to floor 1; otherwise set to false callTo2 Set to true if the elevator is called to floor 2; otherwise set to false 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 code segments for making a Scratch program which simulates a conversation between the user and a sprite on-screen are given below. 1 ask "whats your name" 2 say the answer for 2 seconds 3 say "hello I'm Scratch!" for 2. seconds 4 say "nice to meet you" for 2 seconds 5 When green flag clicked. Which of the following orders is most suitable if the program is to run without errors and produce the most realistic appearing conversation?

5-3-1-4-2

For her 4th of July weather report, a local meteorologist wishes to predict the likelihood of the scheduled fireworks show being rained out by analyzing the most recent weather trends in the local vicinity. Which of the following sources of data would be the most appropriate for helping her make the prediction?

A list of floating-point values representing the daily rainfall totals for the previous 10 days (June 24th through July 3rd)

Which of the following are examples of abstraction?

A programmer writes a procedure called volumeSphere which has a parameter radius and computes the area of a sphere with that radius. She uses this in her code each time the volume of a sphere needs to be computed. AND Logic gates are drawn on a circuit diagram to indicate where two binary values are compared

While writing a program to regulate the speed of a self-driving car, you find that your software sometimes miscalculates the ideal car speed for city streets to be over 1500 MPH (nearly twice the speed of sound), when it should be approximately 30 MPH. Which of the following strategies would be most efficient to employ in debugging your program?

After each calculation within your program, insert a temporary statement that displays the most recently calculated value. When running your program, compare the displayed values with the expected values to identify where in the program the error is being introduced.

The following two algorithms are designed to find the minimum value in a list of integers. Algorithm I: Create a variable min, and set this to the first value in the list. Compare each subsequent value in the list against the value of min, and if it is smaller than or equal to the current value, set min to this value. When the end of the list is reached, display the value of min. Algorithm II: Create a variable min, and set this to 0. Compare each value in the list against the value of min, and if it is smaller than the current value, set min to this value. When the end of the list is reached, display the value of min. Which of the following statements correctly demonstrates that the two algorithms are NOT equivalent?

Algorithm I will correctly display the minimum value of the list [4, 10, 6, 1], but Algorithm II will not

Many tasks, large and small, can be solved by performing a specific set of actions and making a particular set of decisions in very precise ways. These sets of actions and decisions are known as what?

Algorithms

An entrepreneur has hired a programmer to design software to take user input and convert it to appear a certain way. The programmer is not clear on the assignment, so he asks the entrepreneur to elaborate. Which of the following would be most helpful for the programmer to ask the entrepreneur to do to make the assignment clearer?

Give some examples of user input and what the result should look like

Which of the following statements about high-level programming languages when compared to low-level programming languages is true?

High-level programming languages provide programmers with more abstractions and are easier for people to read

Which of the following types of languages is optimized for machine processing and may be written and expressed as a series of binary digits (e.g., ones and zeros), making it difficult for humans to read and write?

Low-level programming language

Cardel is using Java to write a SaaS program for an educational technology company. He chooses to keep his code private and to protect his work from imitation but may wish to modify or update the code in the future. Which of the following will be most likely to make it easier for him to edit his code in the future?

Naming conventions AND Adequate and appropriate comments

Which of the following is an important step to take before beginning to write the code for a program?

Plan the logic and anticipated input/output of the code

The code will be used for a competition, and Peter does not want to reveal the moves performed by the sprite in his program. Currently the path taken by the sprite is traced on the screen. Which of the following changes to the code will change this and allow Peter to keep the path taken by his sprite hidden?

Removing the pen down block

When the green flag is clicked, each of the three scripts is intended to run in turn, however, due to a mistake in the code, this does not happen. Which of the following changes could Tom make to ensure that all four of the scripts run as intended?

Replace the block broadcast sound3 with the block broadcast sound 2

As part of the lifecycle of a program, after a computer programmer writes the code, it is then compiled and usually used to create an executable file to be run on the CPU. The code that is run through the compiler is known as what?

Source Code

Consider constructing an algorithm for a robot that can only perform the following three predefined operations. MOVE_FORWARD ( ): The robot moves one square forward in the direction it is facing ROTATE_LEFT ( ): The robot rotates in place 90 degrees counterclockwise (i.e., makes an in-place left turn) ROTATE_RIGHT ( ): The robot rotates in place 90 degrees clockwise (i.e., makes an in-place right turn) Which of the following algorithms will successfully cause the robot to trace out a square-shaped path, with the robot ending up in its original position and facing in its original direction?

Step 1: MOVE_FORWARD ( ) Step 2: ROTATE_LEFT ( ) Step 3: MOVE_FORWARD ( ) Step 4: ROTATE_LEFT ( ) Step 5: MOVE_FORWARD ( ) Step 6: ROTATE_LEFT ( ) Step 7: MOVE_FORWARD ( ) Step 8: ROTATE_LEFT ( )

A group of high school students is participating in a mobile application development contest. They have a limited time frame and would like to add many features. Which of the following strategies will allow them to create the best app they can in the time allotted? Strategy I: The students outline all goals. They make a program with all procedure names. They use software to simultaneously work on different parts of the code, frequently compiling and testing all code together. As each individual student completes one procedure, that student moves onto the next procedure. Strategy II: The students outline all goals. They work together on some shared code, and students work with their own copies of the code on specific parts. They check in regularly and completed, correct code is added to a master program.

Strategy 2 only

Which of the following could be considered part of the beginning "state" of a Scratch program?

The value of a variable The background image Visibility of sprites

Imagine you are programming a simple calculator using Scratch and you want to create a feature which adds a fixed number to an existing variable named "balance". Which of the blocks below will be the most appropriate to use for this feature?

change "balance" by ( )

Joanna wishes to create a variable in her Scratch game which records the number of seconds until the game ends. Which of the following would be the most appropriate name for this variable?

time_left


Conjuntos de estudio relacionados

Accounting Chapter 3 | 3.2 Accounts, Debits, and Credits

View Set

Ch. 3 - Demand Analysis - Market Analysis Applications--highest and best use appraising

View Set

NUR 221 - Ch 25 WB - Patients with Hepatic and Biliary Disorders **

View Set