No student devices needed. Know more
39 questions
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?
Error check
Debugging
Development
Coding
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→maintain→debug
Idea→algorithm→write code→debug→execute code→maintain
Idea→write code→algorithm→execute code→debug→maintain
Idea→algorithm→write code→execute code→debug→maintain
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?
Develop all of the major algorithms which will be required for the app by drawing flowchart representations
Write thorough documentation explaining how the code for the app works
Write some sample code to understand how the app might work
Find out from the businesses and potential visitors what information and format they think should be used for the app
Which of the following is the MOST important reason computers use artificial languages over natural language?
The meaning of different characters and words in an artificial languages is explicit and unambiguous
The syntax of natural languages is easy to translate by computers
The syntax of artificial languages is explicit and unambiguous
The meaning of different characters and words in an artificial languages is too complicated
Which of the following best describes high-level computing languages?
They are not very ambiguous
They are extremely difficult for humans to read and understand
They evolve naturally over time
They are very easy for machines to understand and parse
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) + 1
RANDOM(a,b) + 2
RANDOM(a,b) * 2
RANDOM(a,b) - 2
Which of the following describes the part of a computer which stores instructions and information which has been input to the computer?
CPU
Binary
RAM
Machine Code
Which of the following best describes “compilation” in reference to computer science?
Memory is set aside to store variables and instructions so that a program can be executed.
Code in a high-level language is converted to low-level instructions which can be interpreted and run by the CPU.
Instructions are repeated a set number of times, or until some specified objective is completed.
Algorithms which have been planned, for example using flow-charts, are written in code.
Which of the following best describes how a compiled program is run by a computer?
The instructions are read directly from the computer hard disk, and the RAM and CPU work separately to execute different parts of the code as it is read.
The CPU converts instructions into binary. RAM is used to look through and interpret these instructions which are then executed by the CPU.
The binary instructions from the program are loaded into RAM. The CPU reads and executes instructions, storing and accessing data from RAM as needed.
The instructions stored in the CPU are sent to RAM, where they are read and executed. Outputs for the program are then sent back to the CPU so they can be displayed.
Consider the following actions which might be performed by a developer when creating a new piece of software to solve a problem.
1. Thoroughly testing code with a variety of inputs
2. Designing an algorithm to tackle the central problem the program hopes to solve
3. Considering what outputs a program solving the problem might produce and what inputs it may require to do this
4. Writing code in a high-level programming language to implement an algorithm
In which order in the development cycle would these actions first appear?
3, 2, 4, 1
2, 4, 1, 3
2, 3, 4, 1
3, 4, 1, 2
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?
Select two answers.
Add statements to display the state of the program at various points to try and identify where the error might have occurred.
Continue to write code, but look for ways in which the error from this part of the program can be corrected or compensated for.
Try changing some of the inputs to see under what circumstances the program is not working and what type of error may be occurring.
Retype each statement in the program again, being extra careful not to make mistakes this time.
Which of the following is a reason for the importance of variables in programming?
Variables assist in making code more readable.
Variables allow you to change a value used in multiple places in a program easily.
Variables allow you to store values calculated by the program and access them at a later point in the program.
All of these
Which of the following are benefits of well-named variables? Select two answers.
The program will be easier to read.
The program will run faster.
The program will be easier for others to debug.
The program will use less resources.
Consider the following algorithm which uses an integer variable n.
Which of the following statements best describes the predictability of the results when this algorithm is run on a computer?
It is impossible to predict the value of the answer displayed, even if the value of n is known.
The answer displayed by the algorithm can be predicted for some values of n, but not for others.
he algorithm always displays the same answer, regardless of the value of n.
The answer displayed by the algorithm for any known value of n can always be predicted.
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.
The memory required to store the variables will be reduced as the possible values which can be stored by each variable can be determined from their names.
The compiler will be able to parse the code faster since it will know the purpose of each variable.
The code will run with fewer errors since the CPU can interpret what the variable represents from its name.
Which of the following describes good practice when naming variables in code?
Select two answers.
Use names which contain as few different characters to aid the compiler and shorten compile times.
Use concise names to avoid typos and keep code tidier.
Use names which describe what each variable represents to make code easier to understand.
Use names which show in what order the variables were introduced to make it easier to find the value of a variable.
Using the flowchart above, what value when entered for Y will generate a mathematical error and prevent our flowchart from being completely executed?
1
3
0
None of these values will produce a mathematical error.
In a flowchart, a typical decision symbol has what type of output?
None of these
numerical
text
boolean (true/false)
Which is NOT true about comments in programs?
Commenting helps programmers develop and maintain programs to efficiently solve problems.
Commenting helps while working collaboratively in programming environments.
All published programs have their comments available.
Commenting about program components helps in developing and maintaining programs.
Which of the following best describes the type of language used in the below algorithm?
Prompt user for number
if number is greater than or equal to 0
Output “Positive”
else
Output “Negative”
Repeat 4 times
Pseudocode
High-level language
Low-level language
Natural language
The algorithm below is used to simulate the results of rolling a standard 6-sided die 5 times. Consider the goal of determining whether the simulation resulted in more results which were odd than results which were even.
Step 1: Initialize the variables odd_counter and roll_counter to 0.
Step 2: A variable dice_roll is randomly assigned an integer value between 1 and 6 inclusive. If dice_roll has a value of 1, 3 or 5, then odd_counter is incremented by 1.
Step 3: Increment the value of roll_counter by 1.
Step 4: Repeat steps 2 and 3 until roll_counter equals 5.
Following the execution of the algorithm, which of the following expressions indicates that the simulation resulted in more results which were odd than results which were even?
odd_counter>2
odd_counter>3
roll_counter>2
roll_counter>3
If the variable score has a value of 10 at the beginning of a program, which runs according to the following flowchart, what will the value of score be at the end?
11
10.5
10
13.5
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 it more understandable for the faculty?
Select two answers.
Choose meaningful names for all variables and procedures.
Include comments detailing previous, unsuccessful coding attempts.
Include comments detailing the purpose and behavior of variables and procedures.
Repeat blocks of code to emphasize their importance in the process.
What must you consider when determining the efficiency of an algorithm? Select two choices.
The length of time required to run the program
The language in which the program is written.
The number of characters used to write the program
The amount of resources, such as storage, required
Elsa and her friend Olaf are co-owners of the world's largest ice cream truck, offering their customers the choice of 256 different flavors of ice cream. The truck, which has been built from an 18-wheeled tractor-trailer, houses the 256 tubs of ice cream in the refrigerated trailer. The side of the truck displays a large list of the 256 names of the different flavors, which the customers then name when they place their orders.
Business is booming and the duo needs to serve their customers quickly. However, in order to quickly find the right tub of ice cream out of such a large collection, Elsa and Olaf both agree that they need to use an efficient solution. Elsa suggests that they organize the flavors alphabetically while Olaf suggests that they organize the flavors in order from his favorite to his least favorite.
Which of the following solutions would allow these ice cream peddlers to find the customers' chosen flavors the most efficiently?
Organize the tubs alphabetically by flavor name and use a binary search algorithm to find the customer's requested flavor.
Organize the tubs according to Olaf's preferences and use a sequential search algorithm to find the customer's requested flavor.
Organize the tubs according to Olaf's preferences and use a binary search algorithm to find the customer's requested flavor.
Organize the tubs alphabetically by flavor name and use a sequential search algorithm to find the customer's requested flavor.
Under which of the following conditions is it most beneficial to use a heuristic approach to solve a problem?
When the problem can be accurately solved in a reasonable time and an exact solution is needed.
When the problem cannot be accurately solved in a reasonable time and an approximate solution is acceptable.
When the problem can be accurately solved in a reasonable time and an approximate solution is acceptable.
When the problem cannot be accurately solved in a reasonable time and an exact solution is needed.
Which of the following will cause an algorithm to fall into an infinite loop?
The algorithm uses more than one loop
The input operations are missing
The condition of the loop never becomes false
The output operations are missing
Which of the following illustrates an aspect of efficiency?
Size of program
Execution time
Memory usage
All of these
The diagram below shows a circuit composed of three logic gates labeled OR and AND. Each gate takes two inputs and produces a single output.
If inputs B and C are both true, which of the following best describes the final output produced by the circuit?
The output will be true if input A is true, and false otherwise.
The output will be true if input D is true, and false otherwise.
The output will be true if both inputs A and D are true, and false otherwise.
The output will be true regardless of the values of inputs A and D.
Which of the following can be represented by a single binary digit?
A darkness setting on a toaster
The direction of travel for an elevator
The speed limit on a major highway
The temperature setting of a thermostat
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?
Do you prefer Mac or PC computers?
When you write with a pen or pencil, which hand do you use?
Would you like to go to the store?
Which of the following statements about 32-bit binary values is NOT true?
All whole numbers within a finite interval can be expressed by a 32-bit integer representation.
All whole numbers within a finite interval can be expressed by a 32-bit floating-point representation.
All real numbers within a finite interval can be expressed by a 32-bit integer representation.
All real numbers within a finite interval can be approximately expressed by a 32-bit floating-point representation.
What is the binary equivalent to the decimal number of 78?
1001110
1110001
1100110
1001100
Which of the following decimal values, when converted to binary (ignore leading zeros) have exactly 3 zeros in them?
Select two answers.
50
30
20
40
ASCII is a common format for the representation of characters in writing code. How many characters can be represented in the standard ASCII encoding?
216
215
28
27
Using the table given below, determine the ASCII to binary code conversion for the word science.
01110011 01100011 01101001 01100011 01100101 01101110 01100101
01110011 01100011 01101001 01100101 01101110 01100101 01100011
01110011 01100011 01101001 01101110 01100011 01100101 01100101
01110011 01100011 01101001 01100101 01101110 01100011 01100101
The following steps can be used to encode a string of text using Base64 encoding:
1. Convert the ASCII characters to their corresponding decimal value
2. Convert the decimal values to their 8-bit equivalents
3. Join all of the bits together to form one continuous string
4. Split the combined string into groups of 6 bits
5. From left to right, convert each group of 6 bits to their corresponding decimal values
6. Convert those decimal values back to the corresponding Base64 values
If I started with the three ASCII characters “CSP”, how many Base64 values will I be left with at the end?
6
4
2
24
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?
An error message will be produced
The program gives us the number 5 because it comes after 4
The output will be 1
The output will be 4
Sometimes we care about the order of a list, and need to reorder the items according to a condition (alphabetical, numerical, etc). An algorithm finds the minimum value in the list and swaps it with the value in the first position, then repeats these steps for the remainder of the list, swapping with the second position, then the third position and so forth. What type of sorting is this?
insertion
bubble
selection
shuffle
Explore all questions with a free account