AP Computer Science Principles - Programming Review

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

An artist is using a programming language to make an interactive piece of art. He elects to keep his code private, to protect his work from imitation. Although they do not affect how his code runs, which of the following will make his code easier to edit in the future? Select two answers A. Adequate and appropriate comments. B. Syntax of the language C. Testing of the code with various inputs D. Naming conventions

A. Adequate and appropriate comments. D. Naming conventions

The following question uses a robot in a grid of squares. Which of the following will cause the robot code to stop executing? A. The robot is stuck with nowhere to move B. The robot is in an infinite loop C. The condition in an "if" statement is not met D. The robot attempts to move off the grid

D. The robot attempts to move off the grid

What are the two aspects of efficiency? A.execution time and memory usage B. memory usage and length of code C. execution time and length of code D. wall clock time and CPU time

A. execution time and memory usage

Which of the following are benefits of using well-named variables in a computer program? Select two answers. A. The program will run faster. B. The program will be easier for people to read. C. The program will have a greater data storage capacity. D. The program will be easier to modify in the future.

B. The program will be easier for people to read. D. The program will be easier to modify in the future.

Which of the following Boolean expressions are equivalent to the expression num ≥ 15 ? Select two answers. A. (num > 15) AND (num = 15) B. (num > 15) OR (num = 15) C. NOT (num < 15) D. NOT (num < 16)

B. (num > 15) OR (num = 15) C. NOT (num < 15)

Which of the following is NOT a use of application programming interfaces (APIs)? A. Allowing software components to communicate B. Simplifying complex programming tasks C. Justifying a program's complexness D. Sharing a library of available procedures

C. Justifying a program's complexness

Which of the following statements are true about high-level programming languages? Select two answers. A. A high-level programming language often uses natural language elements. B. A high-level programming language does not ensure program reliability. C. A high-level programming language must be used to execute commands such adding and multiplying. D. a high-level program langauge allows for code re-use

A. A high-level programming language often uses natural language elements. D. A high-level program language allows for code re-use

A team of students is collaborating on a program to obtain local weather data from a website, and predict weather-related school closings based on their own formulas. They must present their code to a group of faculty, some of whom have little to no experience with code. What strategies can the group use while writing their code, in order to make more understandable for the faculty? Select two answers. A. Choose meaningful names for all variables and procedures. B.Include comments detailing previous, unsuccessful coding attempts. C.Use shorter blocks of code whenever possible. D. Repeat blocks of code to emphasize their importance in the process.

A. Choose meaningful names for all variables and procedures. C.Use shorter blocks of code whenever possible.

What is a benefit of collaborating on code? A. Collaboration can decrease the complexity and size required by individual programmers B. Collaboration can make a program run more efficiently C. Collaboration can reduce a program's file size D. There is no benefit to collaborating

A. Collaboration can decrease the complexity and size required by individual programmers

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 do to make the assignment more clear? A.Give some examples of user input and what the result should look like. B. Write some sample code to show the programmer exactly what he wants C. Sit side-by-side throughout the debugging process D. Select the most appropriate language for the application

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

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? Select two answers. A. Multiple inputs can be tested to determine how much cpu time would be required for the algorithm to solve the problem for inputs of different sizes. B. Ensure that all inputs are limited in complexity. C. Count the number of statements in the program. D. Multiple inputs of various sizes and with different expected outputs can be tested to determine the behavior of the algorithm.

A. Multiple inputs can be tested to determine how much cpu time would be required for the algorithm to solve the problem for inputs of different sizes. D. Multiple inputs of various sizes and with different expected outputs can be tested to determine the behavior of the algorithm.

What measures can a programmer take to help ensure that a program produces correct output? Select two answers A. Test multiple inputs on the program B. Find the efficiency of the code C. Develop the program in smaller steps, ensuring each step is correct D. Calculate the time it takes to run the program

A. Test multiple inputs on the program C. Develop the program in smaller steps, ensuring each step is correct

Which of the following is NOT true about programming documentation? A. The Digital Millennium Copyright Act requires that all documentation for published programs is available, while protecting artists and programmers B. Program documentation helps programmers develop and maintain correct programs to efficiently solve problems C. Program documentation about program components helps in developing and maintaining programs D. Program documentation helps while working collaboratively in programming environments

A. The Digital Millennium Copyright Act requires that all documentation for published programs is available, while protecting artists and programmers

A program is expressed in a programming language. Which of the following is true of the program? A. The program can also be expressed as binary code, but will be more easily understood by humans when expressed in a higher-level programming language. B. The program can also be expressed as binary code, which will reduce the likelihood of errors. C. The program cannot be expressed as binary code, because binary code can only be used to represent data. D. Some parts of the program can be expressed as binary code, but operations must be expressed using a higher-level programming language.

A. The program can also be expressed as binary code, but will be more easily understood by humans when expressed in a higher-level programming language.

A student writes a program to find the factorial of a number. The factorial for a number n is defined as the product of all whole numbers between 1 and n, inclusive. While attempting to find the factorial for 120, the program's output is not what the student expected. Assuming that the program has been correctly written, what is a possible explanation for the incorrect output? A. Real numbers are approximated by floating-point representations that do not necessarily have infinite precision. B. Integers may be constrained in the maximum and minimum values that can be represented in a program because of storage limitations. C. Factorials are an antiquated concept, and modern program languages do not have the operations available to handle them. D. Although correct, the program did not make use of procedures, which made it unstable.

B. Integers may be constrained in the maximum and minimum values that can be represented in a program because of storage limitations.

What is the best way to ensure a large program works correctly? Select two A. Run a test of the program one time, look for any errors B. Add parts to the program that you have tested before, one at a time C. Do not test your program and trust that you are good at programming D, Test your program in different instances

B. Add parts to the program that you have tested before, one at a time D. Test your program in different instances

A programmer is deciding between using a linear or binary search to find a target value in a sorted list. Which of the following is true? A. In all cases, a binary search of a sorted list requires fewer comparisons than a linear search. B. Generally, the advantage of using a binary search over a linear search increases as the size of the list increases. C. A linear search will generally run faster than a binary search because a linear search requires fewer lines of code to implement. D. Using a linear search is preferable to using a binary search if there is a chance that the target may not be found in the list.s

B. Generally, the advantage of using a binary search over a linear search increases as the size of the list increases.

A programmer is writing a program that is intended to be able to process large amounts of data. Which of the following considerations is LEAST likely to affect the ability of the program to process larger data sets? A. How long the program takes to run. B. How many programming statements the program contains. C. How much memory the program requires as it runs. D. How much storage space the program requires as it runs.

B. How many programming statements the program contains.

Which of the following best describes an undecidable problem? A. Heuristic methods are used to find a reasonable, but not the best, solution. B. No algorithm can be constructed that always leads to a correct yes-or-no answer. C. A binary sequence may or may not be applied correctly, given the particular data set. D. Some data sets are so large that it is impossible for computing tools to facilitate the discovery of connections in information.

B. No algorithm can be constructed that always leads to a correct yes-or-no answer.

Which of the following can be represented by a single binary digit? Select two answers. A. The position of the minute hand of a clock. B. The remainder when dividing a whole number by 2. C. The value of a Boolean variable. D. The volume of a car radio.

B. The remainder when dividing a whole number by 2. C. The value of a Boolean variable.

Which of the following programs is most likely to benefit from the use of a heuristic? A. A program that calculates a student's grade based on the student's quiz and homework scores. B. A program that encrypts a folder of digital files. C. A program that finds the shortest driving route between two locations on a map. D. A program that sorts a list of numbers in order from least to greatest

C. A program that finds the shortest driving route between two locations on a map.

In researching a local deer population, a scientist has gathered much information about the deer and is going to write a program to model population growth over time. She wants to analyze how illness and population size are related to available food sources. Which of the following factors most likely does not need to be included in her program: A. Population size. B. Food supply. C. Antler size. D. Prevalence of illness in herd.

C. Antler size

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 times will move on to the next level of the competition. What strategy should the team take? A. Have the robot create a virtual map of the maze, return to the starting position, calculate the quickest route, and take it. B. Program the robot to move at maximum speed, turning left or right at random until it finds the end. C. Use a language most appropriate to the problem at hand, and us built-in functions, such as rotate(RIGHT) and move(), to have the robot complete the task. D. Create an algorithm which, although not finding the ideal solution, finds a reasonable solution quickly.

D. Create an algorithm which, although not finding the ideal solution, finds a reasonable solution quickly.

Which of the following statements is true? A. Every problem can be solved with an algorithm for all possible inputs, in a reasonable amount of time, using a modern computer. B. Every problem can be solved with an algorithm for all possible inputs, but some will take more than 100 years, even with the fastest possible computer. C. Every problem can be solved with an algorithm for all possible inputs, but some of these algorithms have not been discovered yet. D. There exist problems that no algorithm will ever be able to solve for all possible inputs.

D. There exist problems that no algorithm will ever be able to solve for all possible inputs.

When choosing a programming language, which of the following will not be determined by the choice of language? A. The clarity and readability of the code. B. The data structures available. C. The syntax highlighting options available. D. Whether or not a solution exists.

D. Whether or not a solution exists.


Ensembles d'études connexes

environmental science final exam

View Set

FL Review (AAMC Stuff + BP FL 1 + BP FL2 + BP FL 3+ BP FL 4)

View Set

AP Bio Chapter 3 Practice: Water and the Fitness of the Environment

View Set

Final Exam International Business Transactions

View Set