General 1st Sem Review
*Planning a Program Eric is going to write a program for the math teachers at his school that will help them keep track of book numbers across the department. Before he can begin planning this program, what vital info will he need? (2 answers) A) Any concerns that the teachers have about how the program will work B) How many teachers are in the math department C) What algorithms he will need in order to create the program D) A description of what the user interface should look like and how the teachers will interact with the program
A & D (B is not necessary for planning stage)
*Too Big, Too Small, Just Right A website has files on schools with quantitative info to help convey what the school values for sharing with colleges. The website requires that the file size must be below a certain threshold of size. Why might the website restrict this? A) Fairness to schools that did not submit documents B) To minimize storage on their webserver C) The internet cannot support sending large files D) In order to keep the files sortable
B (bc most businesses that run sites are in charge of the files on it, either by providing hardware or renting space on hardware) (A is wrong bc submitting files is not a paid service; C bc it is not a LONG TERM concern; D bc the files are not records that could be sorted in any meaningful way)
*Iteration
B & C
*Programmers at Every Level Which of the following statements about programming are TRUE? (2 answers) A) The same programming standards (such as algorithm use, formatting guidelines, and method of writing comments) must be adhered to in every situation. B) The purpose of the program will determine what kinds of algorithms, helper methods, and strategies the programmer will need to use. C) A program created for a small group of people might be useful for a different purpose for large groups of people D) Programmers at every level focus on creating code that is time efficient above all
B & D
*Variable Swap Alejandro wants to write code that will swap the values of two variables, (x) and (y). He knows that he needs to create a temporary variable (temp) but is unsure how to make the program work correctly. Which of the following code segments will correctly swap the values of (x) and (y)? (2 answers) A) x <- y temp <- x y <- temp B) temp <- x x <- y y <- temp C) temp <- x y <- temp x <- y D) temp <- y y <- x x <- temp
B & D
*Change the Line
C
*How Many Times Does the Algorithm Loop?
C
*Using Substring | 2
C
Logic Gates & 3 Inputs
C
Nested If Statements
C
Talent Show Voting A tv show has contestants with diff talents. After the contestants show talents, each of 3 judges gives a thumbs up or down. The audience also votes, and it a majority votes thumbs up, then the overall audience is thumbs up. The final results are indicated in a sequence of 5 bits, with the rightmost 3 bits representing the 3 judges' votes, the leftmost bit representing the online vote, the bit second to the left representing the overall live audience vote. A bit value of 1 is thumbs up; 0 is thumbs down. The 3 judges votes are weighted twice as high as online/live ones. The winner is the contestant with the greatest value of weighted votes. The following are the final voting results: A: 11001 B: 10110 C: 01101 D: 00111 Which contestant won?
D
When Should a Constant Be Used? A constant is a special type of variable sometimes used to represent a piece of info. Which of the following is the best situation for using a constant to represent something in a program? A) A player's current score in a game B) The number of times a loop has executed C) The name of the leader in a bowling app D) The maximum number of lives a player can have in a game
D
A company has 8 machines with a number 0-7, and the status of each is a sequence of bits. 1 means the machine is in service; 0 means it's out of service. The status of machine 0 is represented by the rightmost bit and machine 7's status is the leftmost bit. The company communicates the status of its machines to its supervisors by using the decimal equivalent of a byte. If the status of machines is 52, then what machines are currently in service?
Machine 2, 4, and 5
Addition of Binary and Decimal Numbers If a number is represented by 0010 1001, and it is processing an instruction to add 21, what is the resulting number in binary?
0011 1110
Basic Math Engine Using Bits A 3-byte program has the first byte as an integer (12), the second as an operation (division), and the third as another integer (3). (ex. 12 / 3). The engine returns the result in decimal. 0000 0010 is multiplication. 0001 0000 0000 0010 0000 0011
48
*Gaming Algorithm
A
*Inputs & Outputs of a Procedure
A
Life on Mars: Day 1
A
Using Substring
A
*Two Binary Digits Which of the following can be represented by exactly 2 binary digits? (2 answers) A) Compass directions (N, S, E, W) B) Classifying a student by whether or not they are passing and whether or not they have perfect attendance C) The first letter of someone's last name D) A person's height
A & B
Maintaining Programs Alvin is working on creating a fairly large program. Which of the following strategies will make his code easier to maintain once the program is finished? (2 answers) A) Using procedures fo repeated code B) Testing one part of the program before writing more code C) Writing documentation for all procedures and variables in the program D) Breaking the program into smaller parts and testing each part separately
A & C (A & C improve readability of code; B helps debug not maintain; D helps develop but not maintain)
*Debugging Which of the following might help a programmer with debugging? (2 answers) A) Well named variables and procedures B) Completing the entire program before testing C) Inserting statements like "loop completed" or "if statement starts here" that display as the code is running D) Running the code with a test case
A & C (A bc understanding what the code does helps for debugging; C bc it can help visualize where the error happens) (B is wrong bc waiting till the end is hard to find small errors; D bc ONLY one test case will not help find all errors)
Binary Digit Which of the following can be represented by a single binary digit? (2 answers) A) Any integer modulus 2 B) The temp outside C) The score on a math test D) If a grade is passing or failing
A & D
Strategies for Program Development Which of the following strategies help programmers develop a correct program to solve problems? (2 answers) A) Writing part of the code and testing before writing next part B) Working on all of the code in as few sittings as possible C) Waiting until the end of writing to test the code D) Splitting the code into components, writing and testing them separately, then combining the components
A & D (A avoids errors by testing; D avoids errors by separating into parts to test) (B is not relevant with good documentation; C creates large errors)
*Repeat & Return
B
And, Or, and Not II
B
Boolean Expression
B
Concatenating Strings
B
Counter Total
B
Determining Procedure Functionality Based on Expected Output (easy)
B
*Why Use Program Documentation? Of the following, which is the LEAST important reason for including documentation in computer programs? A) To describe the purpose/parameters of a procedure, so that maintenance is easier in the future B) To clarify well-named variables in the code so that you know what they represent C) To highlight areas of code that are either incomplete or contain known issues D) To provide insight into the code that offers knowledge transfer to other programmers
B (bc if the variable is well-named, its representation is clear and doesn't need documentation to clarify) (A is wrong bc describing purpose is good for documentation; C bc highlighting areas with errors is good for debugging; D bc documentation is good for sharing with other coders)
What Data Can Be Stored in 3 Bits? Binary representation can be used to denote diff types of info. Given that you only have 3 bits to store data, which of the following can be best represented in these 3 bits? A) The number of holes played in the first 3 hours of a golf round B) The number of pins knocked over in the first frame of a bowling game C) The number of dots shown on the top face of a standard die after rolling it in a board game D) The number of face cards (jacks, queens, kings) not yet dealt from a standard deck of 52 cards
C
Program Functionality Which of the following would be the best explanation of the functionality of a program? A) The Tic Tac Toe program looks for spots where it can win. If there are no such spots, it checks for spots where it can block the players move B) The program locates the highest card in the deck by using the binary search algorithm C) The user calculates their bill by entering the price of each item they plan to purchase. The user then clicks "calculate" to determine the total cost D) The program asks the user for a word, then translates the word into pig latin. The program does this using the substring procedure and concatenation
C (bc it only describes the way the user will interact with it)
Binary can represent data like: images, data, numbers, text, and sound. Which of the following could NOT be represent by the sequence 0100 0001? A) A B) 65 C) 1011 1110 D) The amount of red in an RGB model
C (bc one binary sequence can't represent a different one)
Variable Naming What are the benefits of well-named variables in a program? (2 answers) A) The program will run faster B) The program will require less memory C) The program allows others to read it more easily D) The program will be easier to edit
C & D (A is wrong bc naming variables has no effect on running speed; B bc memory is not relevant to variable naming)
Boolean is a Licensed Driver 2
D
Know Your X, Y, Zs x <- 3 y <- 7 z <- 21 x <- y y <- z DISPLAY (x) DISPLAY (y) Which of the following will be displayed after the code is run? A) 3 7 B) 3 3 C) 21 21 D) 7 21
D
Sequence of bits What does this sequence represent?: 0110 1011 0010 1011 A) A number B) Data C) Instructions for the computer D) Something that depends on the context in which it is used
D
The Same Binary Sequence Jerry and Ron are working on programs with different purposes and implementations. They each use the following binary sequence in their programs: 0110 1100 0100 0111 What is true of the binary sequence representing data?
This binary sequence MIGHT represent the same type of data.
*Logic Gates Using 4 Gates
D