AP Computer Principles Midterm

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which of the following best describe examples of abstraction?

-A developer writing a program for calculating properties of shapes uses a variable pi to store a decimal approximation of the number π (~3.14159). They use this variable whenever they need to use the number π to calculate an area or volume. -A sheet of music for guitar is written as a series of chords (e.g C, Am, G7). Each of these represents multiple notes which are played simultaneously on different strings of a guitar.

Tamara is writing code as part of a large project. She has just compiled her code and run it, but the result is not exactly as expected. Which of the following strategies would be efficient ways to "debug" her code so that it works as intended?

-Add statements to display the state of the program at various points to try and identify where the error might have occurred. -Try changing some of the inputs to see under what circumstances the program is not working and what type of error may be occurring.

Which of the following should be true of any algorithm?

-I. The order in which the steps making up the algorithm are followed is logically determined -III.The instructions in the algorithm contain all necessary information to be implemented

Step 1: Using a random number generator, get a value between 1 - 6 inclusively Step 2: Remember that number Step 3: Repeat steps 1 and 2 Step 4: Add the two remembered numbers together Step 5: Multiply that sum by 10 Step 6: Divide the result of that multiplication by 2

-If the last digit of the value found in step 6 is 5, then the sum is odd -If the value found in step 6 is 10, 20, 30, 40, 50 or 60 then the sum is even

Double the value of n Add 34 to the answer Round the answer to the nearest ten Sum the digits of the answer Display the final answer Which of the following statements best describes the predictability of the results when this algorithm is run on a computer?

-The answer displayed by the algorithm for any known value of n can always be predicted.

Which of the following are benefits of well-named variables?

-The program will be easier to read. -The program will be easier for others to debug.

Which of the following describes good practice when naming variables in code?

-Use concise names to avoid typos and keep code tidier -Use names which describe what each variable represents to make code easier to understand

In which order in the development cycle would these actions first appear?

1.Considering what outputs a program solving the problem might produce and what inputs it may require to do this 2.Designing an algorithm to tackle the central problem the program hopes to solve 3.Writing code in a high-level programming language to implement an algorithm 4.Thoroughly testing code with a variety of inputs

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

2^7

How many distinct values can be represented with 6 bits of data?

64

Which of the following is a valid reason for giving variables meaningful names in a program?

A programmer will find it easier to read and understand the code since they will know what the variables represent.

What is a binary search algorithm?

A search that compares the value sought against the central value of the set to determine which half of the set the value would be found in. It then determines that half to be the new set and does the same again. This process repeats until the sought after value is found. This is a far quicker, and therefore more efficient, algorithm

Consider the following statement which refers to the block (move 10 steps)

Abstraction

Which is NOT true about comments in programs?

All published programs have their comments available.

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

All real numbers within a finite interval can be expressed by a 32-bit integer representation.

Which of the below options would be the best set of instructions to give for a program designed in Scratch?

Click on the GREEN flag. Once the game starts, use the arrow keys to navigate your way through the maze. In your travels, collect the "hearts" for more lives and avoid being eaten by zombies.

Which of the following best describes "compilation" in reference to computer science?

Code in a high-level language is converted to low-level instructions which can be interpreted and run by the CPU.

"The iteration (repetition) pattern repeats a set of instructions until a certain <missing word> is met."

Condition

A program that Thomas has written is complete. It has been tested thoroughly, and some outputs were not as expected. Thomas is now going through the code carefully attempting to establish the cause of these errors and change the code to remove them. What is this procedure called?

Debugging

Which of the following plans would be the most practical and most efficient solution for computing an accurate population count, no matter how large the community grows?

Every year, mail a copy of the census form to every home in the community and require that each household complete the form themselves and mail it back to a central office for processing. Then follow up with those that did not.

Jeremiah is part of a group planning a summer fair at which local businesses can run stalls and events. He wants to use his programming skills to develop an app for the fair which businesses will be able to use to communicate information about their activities at the fair with visitors. Which of the following would be the best first step for Jeremiah to take?

Find out from the businesses and potential visitors what information and format they think should be used for the app

Jama is creating a program which calculates the square roots of whole numbers. The program will store the results of each square-root as a variable. Which of the following data-types would be best used for this variable? int

Float

Which of the following describes algorithmic solutions to problems: I. A set of step by step instructions for assembling a piece of furniture.II. A flowchart used to make important decisions on which actions to take in an emergency situation III. A recipe for baking a cake with detailed numbered steps to follow

I. A set of step by step instructions for assembling a piece of furniture.II. A flowchart used to make important decisions on which actions to take in an emergency situation III. A recipe for baking a cake with detailed numbered steps to follow

Understanding of the life cycle of a program is an essential component to becoming an effective programmer. Which of the following is the best example of how the life cycle of a program should work?

Idea→algorithm→write code→execute code→debug→maintain

Language A:Calculate the average daily rainfall for the week (averageRainfall) by adding together the rainfall totals for each of the 7 days of the week (sun, mon, tue, wed, thu, fri, and sat) and dividing the sum by 7. Language B:Take the total amount of rain from each day of the week (sunday, monday, tuesday, wednesday, thursday, friday and saturday) and then average them together to get the average daily rainfall for the week (averageRainfall). Which of the following statements about these two implementations is true?

Language B is ambiguous because the process of "average" is not explained well

A mathematician is working with a programmer to write a program to solve a problem using high level mathematics. The mathematician asks the programmer to help her determine the efficiency of the algorithm. How can the efficiency be determined?

Multiple inputs of various sizes and with different expected outputs can be tested to determine the behavior of algorithm.

What can't cause mathematical errors by themselves?

Multiplication, addition and subtraction cannot by themselves cause mathematical errors

Rick is in charge of a team developing a program which will be used by businesses to control stock. The team has already consulted with potential clients and developed an idea of what inputs will be required and the likely outputs that will be produced from these inputs. Which of the following should Rick and his team do next?

Plan the structure of the program and determine how the major algorithms will work

A team of students is programming a robot to find its way out of a maze (exact layout unknown) for a national competition. The robot will be timed, and teams with the best time will move on to the next level of the competition. What strategy should the team take?

Program the robot with a simple algorithm which, although not necessarily finding the ideal solution, will eliminate some overly long routes and find a reasonable solution quickly. The robot will then follow this route.

Which of the following describes the part of a computer which stores instructions and information which has been input to the computer?

RAM

A statistics teacher wishes to create a program on her calculator that generates a random even integer. The command built in the calculator to generate a random positive integer is RANDOM(a,b). This command generates a random integer between integers a and b (and including a and b). Which of the following lines of code will ensure that the random integer generated will be even?

RANDOM(a,b) * 2

Which of the following describes a search algorithm which would be very inefficient for finding values in the middle of a large ordered data set?

Sequential

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).

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

Which of the following is a key factor in determining the efficiency of an algorithm?

Storage

What must you consider when determining the efficiency of an algorithm?

The amount of resources, such as storage, required and The length of time required to run the program

Which of the following best describes how a compiled program is run by a computer?

The binary instructions from the program are loaded into RAM. The CPU reads and executes instructions, storing and accessing data from RAM as needed.

Which of the following will cause an algorithm to fall into an infinite loop?

The condition of the loop never becomes false

Which of the following can be represented by a single binary digit?

The direction of travel for an elevator

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?

The output will be 4

The following question uses a robot in a grid of squares. Which of the following will cause the robot code to stop executing?

The robot attempts to move off its grid.

Which of the following is the MOST important reason computers use artificial languages over natural language?

The syntax of artificial languages is explicit and unambiguous

Which of the following best describes high-level computing languages?

They are not very ambiguous

Under which of the following conditions is it most beneficial to use a heuristic approach to solve a problem?

When the problem cannot be accurately solved in a reasonable time and an approximate solution is acceptable.

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

Which is the best song new song from last year?

Which of the following is a simplified but equivalent Boolean expression to the following: (X > 0 AND X ≤ 20) OR (X > -5 AND X < 15)

Which of the following is a simplified but equivalent Boolean expression to the following: (X > 0 AND X ≤ 20) OR (X > -5 AND X < 15)

In a flowchart, a typical decision symbol has what type of output?

boolean (true/false)

Which of the following is a reason for the importance of variables in programming?

iables allow you to store values calculated by the program and access them at a later point in the program. Variables allow you to change a value used in multiple places in a program easily. Variables assist in making code more readable.

Roxanne is writing a program which will be used to display information to passengers on a flight. Some of the variables she will use for her program are as follows. speed - the current speed of the airplane relative to the ground in meters per secondpassengers - the number of passengers on-board the planedestination - the name of the destination airport of the flight Which of the following correctly describes the types which would be best used for each of these variables?

speed - float, passengers - int, destination - string


Ensembles d'études connexes

Pharmacology General Principles: Chapter 4 & 5

View Set

AP Gov Unit 3 : Civil Liberties and Civil Rights

View Set

English midterm review guide (Duran)

View Set

Nutrition: Chapter 4: Carbrohydrates: Sugars, Starches, and Fibers

View Set