AP CSP Semester 1 MC

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

Which of the following decimal values, when converted to binary (ignore leading zeros) have exactly 3 zeros in them? Select two answers. a) 20 b) 30 c) 40 d) 50

a) 20 AND d) 50

What is the binary equivalent to the decimal number of 78? a) 1001100 b) 1110001 c) 1100110 d) 1001110

d) 1001110

Using the table given below, determine the ASCII to binary code conversion for the word science. a) 01110011 01100011 01101001 01100101 01101110 01100011 01100101 b) 01110011 01100011 01101001 01100101 01101110 01100101 01100011 c) 01110011 01100011 01101001 01100011 01100101 01101110 01100101 d) 01110011 01100011 01101001 01101110 01100011 01100101 01100101

a) 01110011 01100011 01101001 01100101 01101110 01100011 01100101

ASCII is a character-encoding scheme that uses 7 bits (8 bits if you are using the extended ASCII table) to represent each character. The decimal (base 10) values 65 through 90 represent the capital letters A through Z, as shown in the table below: Which ASCII character is represented by the binary (base 2) number 1000001? a) A b) C c) B d) D

a) A

Which of the following statements are NOT true about high level programming languages? Select two answers: a) Any particular algorithm will be written in the same way regardless of which high level programming language is used b) Code written using high level languages is guaranteed to be ambiguous c) Code written using high level languages is relatively easy for humans to read, write and parse d) Code written using high level languages usually requires compiling before it can be run

a) Any particular algorithm will be written in the same way regardless of which high level programming language is used b) Code written using high level languages is guaranteed to be ambiguous

The program below calculates and displays the sum of the integers from m to n inclusive, where m < n. Line 1: i ← m Line 2: r ← n-m+1 Line 3: sum ← 0 Line 4: REPEAT r TIMES Line 5: { Line 6: sum ← sum+i Line 7: i ← i+1 Line 8: } Line 9: DISPLAY sum If Line 1 is changed to read i ← n, which of the following changes will ensure that the program continues to calculate and displays the sum of the integers from m to n inclusive? a) Change line 7 to read i ← i-1 b) Change line 6 to read sum ← sum-i c) Change line 3 to read sum ← n d) Change line 2 to read r ← m-n+1

a) Change line 7 to read i ← i-1

Which statements below are true about fixed and variable width encoding? Select two answers. a) Fixed width encodings are typically longer than variable width encodings. b) Fixed width encodings are limited to only 8 bits of data. c) Variable width encoding must use extra bits to specify where characters start/end. d) Variable width encodings will always be longer than a fixed width encoding.

a) Fixed width encodings are typically longer than variable width encodings. AND c) Variable width encoding must use extra bits to specify where characters start/end.

A particular problem is currently not able to be practically solved by using an algorithm. Which of the following statements about the problem could possibly be true? I. No algorithm has yet been developed which would solve this problem, but it is possible one may be developed in the future. II. An algorithm has been developed which would solve this problem but technology is not yet available which would compute this algorithm fast enough to be practicable. III. It is impossible to develop an algorithm which would solve this problem. a) I, II, and III b) I and III only c) I only d) I and II only

a) I, II, and III

The following algorithm is presented for assembling a piece of furniture from 12 individually numbered parts. Parts 1, 5, and 11 Parts 2 and 10 Part 12 Parts 6 to 9 inclusive Parts 3 and 4 Which of the following correctly describe issues with the way these instructions are presented? I. There instructions lack the required descriptive qualifiers II. The instructions lack the required imperative statements III. The order in which the instructions should be performed is unclear a) II only b) I and II c) I only d) I, II, and III

a) II only

Sally notices that she has the same set of 10 blocks in her code in multiple places. She decides to create a new block (procedure) in Scratch so that she can simply replace those 10 blocks with one procedure. Which of the following gives the best ways in which this could be beneficial to Sally when she debugs and reasons through her program? Select two answers. a) If there is an error in the procedure, she can fix the error in the procedure without having to search through her code for each place the procedure is used. b) The procedure will make the program more efficient, spending less time running the same set of 10 blocks over and over again. c) The procedure can make the code section more abstract, so she doesn't have to think through all 10 blocks each time she comes across them in her code. d) She will be able to hide the function of this code block easier meaning others cannot copy her work.

a) If there is an error in the procedure, she can fix the error in the procedure without having to search through her code for each place the procedure is used. AND c) The procedure can make the code section more abstract, so she doesn't have to think through all 10 blocks each time she comes across them in her code.

Which of the following is NOT an advantage of giving variables meaningful names in a program? a) It is easier for a computer to understand the program, meaning compile-times and run-times are reduced b) It is easier for people who are unfamiliar with the code to read the program and understand what it may be doing c) When writing the program a programmer will be less likely to use variables for the wrong purpose d) When editing the program in the future, a programmer will be able to make changes with greater ease and refer to the documentation less

a) It is easier for a computer to understand the program, meaning compile-times and run-times are reduced

The owner of a pet store wants to determine how many fish she can keep in a given aquarium before the population becomes too overcrowded for the fish to survive. Rather than risking the lives of actual fish, she decides to simulate an aquarium with a program in order to determine its maximum capacity. Which of the following would NOT be a useful factor to include when modeling the properties of the simulated tank and fish population? a) The color of the fish b) The amount of food in the tank c) The size of the tank d) The size of the fish

a) The color of the fish

A city engineer is tasked with studying vehicular traffic patterns throughout a large metropolitan area. He designs a number of small, remote devices that can be installed along streets throughout the city to sense and record the hundreds of cars that pass through each of the city's five busiest intersections during a 24-hour period. Every time a car trips the sensor in a device, it increments an internal, 5-bit counter that stores the number of cars that have passed through the intersection since the counter was last reset. Every 24 hours, each device transmits the 5-bit value stored in its counter back to a central server that collects the daily data from all of the devices throughout the city. After transmitting, the counter in each device is reset back to 0. Fortunately, the engineer's supervisor points out a flaw in the device's design and orders that the engineer modify the design specifications for this device before building and installing the sensors. Which of the following is most likely the design flaw in this scenario? a) The counter is not capable of counting hundreds of cars without exceeding the limit of the five bits of storage. b) In order to measure the five busiest intersections, devices will need to be installed at all other intersections throughout the city as well. c) In addition to incrementing the counter, the device should also transmit its counter value after each car trips the sensor. d) The device should only transmit its counter value once per week to avoid overloading the network.

a) The counter is not capable of counting hundreds of cars without exceeding the limit of the five bits of storage.

Which of the following can be represented by a single binary digit? a) The direction of travel for an elevator b) The speed limit on a major highway c) A darkness setting on a toaster d) The temperature setting of a thermostat

a) The direction of travel for an elevator

As movies and music have moved into the digital world, the legal protections that relate to them have had to continually evolve. Which of the following best describes how the legal landscape regarding the digital movies and music has changed? a) The music and movie industries have chosen to protect their copyrights by filing lawsuits against people who share digital files without permission. b) The movie and music industries have actively promoted peer to peer sharing sites as a way to control how digital content is used. c) United States lawmakers have chosen to take a wait-and-see position on the legal issues related to digital media. d) Copyright laws related to digital content have been modified and simplified so that they are easier to understand.

a) The music and movie industries have chosen to protect their copyrights by filing lawsuits against people who share digital files without permission.

Don wishes to swap the values of the variables x and y in his program. He adds a line of code which sets the value of x to the value of y and then a line of code which sets the value of y to the value of x. What is the effect of Don's code? a) The values of both x and y will be set to the original value of y. b) The values of both x and y will be set to the original value of x. c) The values of the variables x and y will be swapped as intended. d) The values of both x and y will be set to the average of the original values of x and y.

a) The values of both x and y will be set to the original value of y.

Which of the following statements about low-level languages are true? Select two answers: a) They are generally less readable by humans than other languages b) They are difficult for machines and humans to parse c) They are relatively easy for humans to write d) They are very rarely ambiguous

a) They are generally less readable by humans than other languages AND d) They are very rarely ambiguous

The following procedure, validate (x), is intended to display "PASS" if an integer, x, is within the range of 128 through 32768, inclusive. Values of x that are not within the range should display "FAIL". Which of the following sets of test cases would be the best choice to fully test this procedure and provide evidence that it executes as intended for all values of x? a) validate(127) validate(128) validate(2048) validate(32768) validate(32769) b) validate(100) c) validate(0) validate(10000) validate(1000000) d) validate(128) validate(512) validate(2048) validate(16384) validate(32768)

a) validate(127) validate(128) validate(2048) validate(32768) validate(32769)

There is a base 6 number system that uses symbols instead of numerals to represent different values. Below is the symbol that represents each numeral. ⤲ = 0 ↺ = 1 ➣ = 2 ⬳ = 3 ⤴ = 4 ⇶ = 5 Which of the following numbers written using this base 6 number system is equivalent to the base 10 number 147? a) ⤴ ⤲ ⬳ b) ↺ ⤲ ⤴ ➣ c) ⬳ ⤲ ⤲ d) None of the options listed

a) ⤴ ⤲ ⬳

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? a) 2 b) 4 c) 6 d) 24

b) 4

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? a) Processes b) Algorithms c) Abstraction d) Building Blocks

b) Algorithms

Consider the given code fragment. Determine the output of the program fragment. m ← 2 REPEAT UNTIL(m > 500) { DISPLAY(m) m ← m + 2 } a) All odd numbers 1 3 5 7 ... 499 b) All even numbers 2 4 6 8 ... 500 c) All even numbers 2 4 6 8 ... 498 d) All numbers 0 1 2 3 ... 500

b) All even numbers 2 4 6 8 ... 500

Which of the following could be considered part of the beginning "state" of a Scratch program? a) The background image b) All of the options listed c) Visibility of sprites d) The value of a variable

b) All of the options listed

The procedure below is intended to return true if a particular city name (cityName) appears more than once in a list of cities (cityList), and false if it does not appear, or only appears once in the list. PROCEDURE CityRepeat (cityList, cityName) { counter ← 0 FOR EACH city IN cityList { IF (city = cityName) { counter ← counter + 1 } } IF (counter = 1) { RETURN false } ELSE { RETURN true } } Which of the following statements about the testing of this procedure is true? a) Calling the procedure CityRepeat (["Chicago", "New York", "Los Angeles", "New York"], "New York") shows that the procedure works as intended in all cases. b) Calling the procedure CityRepeat (["New York", "Los Angeles" "New York", "Chicago"], "Boston") shows that the procedure does not work as intended in this case. c) Calling the procedure CityRepeat with a wide variety of different parameters should show that the procedure works as intended in all cases. d) Calling the procedure CityRepeat (["Chicago", "Chicago", "New York", "Los Angeles", "Chicago", "New York"], "Chicago") shows that the procedure does not work as intended in this case.

b) Calling the procedure CityRepeat (["New York", "Los Angeles" "New York", "Chicago"], "Boston") shows that the procedure does not work as intended in this case.

The county clerk's office is writing a program to search their database for citizen records based on information about that citizen such as first name, last name, age, etc. Given below is a segment of pseudocode that should find the record of every citizen over the age of 50 in the county. The code makes use of the functions GetAgeOf and GetNameOf, which are used to retrieve the age and name of a citizen from a record which is inputted. FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age < 50) { DISPLAY(name) } There is a mistake in this pseudocode. Which of the following is the correct pseudocode to find the records of all citizens over the age of 50. a) FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age = 50) { DISPLAY(name) } } b) FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age > 50) { DISPLAY(name) } } c) FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age > 51) { DISPLAY(name) } } d) FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age < 51) { DISPLAY(name) } }

b) FOR EACH person IN citzlist { age = GetAgeOf(person) name = GetNameOf(person) IF(age > 50) { DISPLAY(name) } }

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? a) Pseudocode b) Low-level programming language c) Natural language d) High-level programming language

b) Low-level programming language

A program is used to print name tags for guests at an event. Unfortunately for each guest it prints the last name before the first name when the opposite is desired. The procedure for printing the name tags uses the variables FN for the first name and LN for last name. Which of the following code segments, inserted in the correct place in the procedure will cause the program to print the name tags in the desired way? a) LN ← FN LN ← Temp FN ← Temp b) Temp ← LN LN ← FN FN ← Temp c) Temp ← LN Temp ← FN FN ← LN LN ← FN d) FN ← LN LN ← FN LN ← Temp

b) Temp ← LN LN ← FN FN ← Temp

A teacher uses the following program to adjust student grades on an assignment by adding 5 points to each student's original grade. However, if adding 5 points to a student's original grade causes the grade to exceed 100 points, the student will receive the maximum possible score of 100 points. The students' original grades are stored in the list gradeList, which is indexed from 1 to n. i ← 1 REPEAT n TIMES { i ← i + 1 } The teacher has the following procedures available. min (a, b): Returns the lesser of the two values a and b max (a, b): Returns the greater of the two values a and b Which of the following code segments can replace so that the program works as intended? Select two answers. a) gradeList [i] ← max (gradeList[i] + 5, 100) b) gradeList [i] ← min (gradeList[i] + 5, 100) c) gradeList [i] ← gradeList[i] + 5 IF (gradeList [i] > 100) { gradeList [i] ← 100 } d) gradeList [i] ← gradeList[i] + 5 IF (gradeList [i] > 100) { gradeList [i] ← gradeList[ [i] - 5 }

b) gradeList [i] ← min (gradeList[i] + 5, 100) AND c) gradeList [i] ← gradeList[i] + 5 IF (gradeList [i] > 100) { gradeList [i] ← 100 }

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? a) shuffle b) selection c) insertion d) bubble

b) selection

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? a) Variable1 b) time_left c) t d) amountOfTimeRemainingInTheGame

b) time_left

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) a) (X < -5) AND (X ≥ 20) b) (X < 0) AND (X > 15) c) (X > -5) AND (X ≤ 20) d) (X > 0) AND (X < 15)

c) (X > -5) AND (X ≤ 20)

ASCII is a common format for the representation of characters in writing code. How many characters can be represented in the standard ASCII encoding? a) 2^15 b) 2^8 c) 2^7 d) 2^16

c) 2^7

Which of the following terms best describes the process of suppressing complex details of a system and presenting a simplified version with just the relevant details? a) Programming b) Creativity c) Abstraction d) Free Thinking

c) Abstraction

Which of the following algorithms require both selection and iteration? Select two answers: a) An algorithm that, given a list of integers, displays the sum of the integers in the list. b) An algorithm that, given two integers, displays the greater of the two integers. c) An algorithm that, given a list of integers, displays the number of even integers in the list. d) An algorithm that, given a list of integers, displays only the negative integers in the list.

c) An algorithm that, given a list of integers, displays the number of even integers in the list. AND d) An algorithm that, given a list of integers, displays only the negative integers in the list.

Which of the following variable types is characterized by allowing only two possible values to be stored? a) Array b) String c) Boolean d) Float

c) Boolean

Which of the following does NOT describe a real benefit from using abstraction in programming? a) By using logic gates to represent a complex collection of components in a digital circuit, someone without an advanced understanding of electronics could determine the purpose and function of the circuit. b) By using an appropriately named variable to store the result of a calculation, a programmer can save time as they will not be required to re-type the calculation each time. c) By storing a set of integers using a list variable, the actual values of these integers can be kept hidden from someone reading the code, increasing security. d) By putting a series of steps which must be performed several times in a program into a separate procedure with a descriptive name, a program can be made more readable.

c) By storing a set of integers using a list variable, the actual values of these integers can be kept hidden from someone reading the code, increasing security.

Which of the following is used in the instructions below to determine how the task of "having breakfast" will be performed? Dump cereal in bowl Pour milk in bowl Eat cereal and milk Place spoon and bowl in dishwasher I. Sequencing II. Selection III. Iteration a) I, II, and III b) I and III only c) I only d) II only

c) I only

Chad has written the majority of his code in Scratch and is ready to start running his program using a variety of carefully chosen conditions to see if it functions properly in all these cases. Which of the following software development terms best describes this process? a) Debugging b) Maintaining c) Testing d) Implementing

c) Testing

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? a) The program gives us the number 5 because it comes after 4 b) An error message will be produced c) The output will be 4 d) The output will be 1

c) The output will be 4

What would be the result of running the program below? list ← [ 1, 2, 3 ] APPEND ( list, 5 ) INSERT ( list, 4, 4 ) REMOVE ( list, 5 ) DISPLAY ( list ) a) The program would display the list [1, 2, 3, 4, 4]. b) The program would display an error message. c) The program would display the list [1, 2, 3, 4]. d) The program would display the list [1, 2, 3, 5, 4].

c) The program would display the list [1, 2, 3, 4].

Which of the following questions cannot be easily answered using a binary set of answers? a) When you write with a pen or pencil, which hand do you use? b) Would you like to go to the store? c) Which is the best song new song from last year? d) Do you prefer Mac or PC computers?

c) Which is the best song new song from last year?

A programmer has two lists of random words, list1 and list2. He has written a program that is intended to create a list, finalList, of all the words found in list1 and list2 in alphabetical order with no repeated words. His program makes use of the following procedures: Alphabetize(list) Returns a list that contains the elements of list in alphabetical order. Join (list 1, list2) Returns a list with the elements of list1 followed by the elements of list2 RemoveDuplicates (list) Returns a list with the same elements in the same order as list, but with any duplicate elements removed. The programmer's program is as follows: list1 ← RemoveDuplicates (list1) list2 ← RemoveDuplicates (list2) finalList ← Join (list1, list 2) finalList ← Alphabetize (finalList) a) finalList, will contain all the words found in list1 and list2 but they may not be in alphabetical order and also contain repeated words. b) finalList, will contain all the words found in list1 and list2 with no repeated words, but these may not be in alphabetical order. c) finalList, will contain all the words found in list1 and list2 in alphabetical order, but it may contain repeated words. d) As intended, finalList, will contain all the words found in list1 and list2 in alphabetical order with no repeated words.

c) finalList, will contain all the words found in list1 and list2 in alphabetical order, but it may contain repeated words.

Which of the following is an example of code written in a high-level programming language? a) 00101100 01010000 11011000 10110111 b) Add the number 2 to the number 5, then subtract this from the number 10 and display the answer. c) num1 = 8 - 3 num2 = 2 * num1 + 1 print(num2) d) LD R0 8 LD R1 3 SUB R1 R0 LD R2 1 ADD R2 R0 ST R0 X

c) num1 = 8 - 3 num2 = 2 * num1 + 1 print(num2)

Which of the following statements about 32-bit binary values is NOT true? a) All real numbers within a finite interval can be approximately expressed by a 32-bit floating-point representation. b) All whole numbers within a finite interval can be expressed by a 32-bit floating-point representation. c) All whole numbers within a finite interval can be expressed by a 32-bit integer representation. d) All real numbers within a finite interval can be expressed by a 32-bit integer representation.

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

The code segment below uses the procedure IsPartOf (list, item), which returns true if item appears in list and returns false otherwise. The list newList is initially empty. FOR EACH item IN oldList { IF (NOT IsPartOf (newList, item)) { APPEND (newList, item) } } Which of the following best describes the contents of newList after the code segment is executed? a) All elements in oldList, including any repeats of elements. b) All elements in oldList which are repeated. c) All elements in oldList which are NOT repeated. d) All unique elements in oldList NOT including any repeats of elements.

d) All unique elements in oldList NOT including any repeats of elements.

Daija is creating a budget, and evaluating his purchases over the last month. Consider the following code segment which attempts to find the sum of all purchases made in the last month, stored in purchaseList. n ← 1 sum ← 0 REPEAT UNTIL () { sum ← sum + purchaseList[n] n ← n + 1 } What code can replace missing code to assign the total of all values in purchaseList to sum? I. n = LENGTH (purchaseList) II. n ≥ LENGTH (purchaseList) III. n > LENGTH (purchaseList) a) II and III b) I, II, and III c) II only d) III only

d) III only

What is displayed as a result of running the following program? a ← 6 b ← 11 IF (a = b) { DISPLAY ("January") } ELSE { IF (a > b) { DISPLAY ("February") } ELSE { IF (a > 0) { DISPLAY ("March") } ELSE { DISPLAY ("April") } } } a) January b) April c) February d) March

d) March

Consider the given code: 1 integer ← 22 2 lowtemp ← 0 3 4 IF(integer < 10) 5 { 6 lowtemp ← lowtemp - 5 7 } 8 ELSE 9 { 10 lowtemp ← lowtemp + 10 11 } 12 13 DISPLAY(lowtemp) What is the best description of the structure implied by line 4? a) Sequencing b) Iteration c) Algorithm d) Selection

d) Selection

Frankie is considering whether to use a binary or linear search in her program to find a value in a sorted list. When she tests the algorithms on selection of short lists of fixed-length lists she finds that the binary search is faster on average than the linear search. Another programmer suggests she tests both algorithms on a selection of lists which are 10 times as long as her original test lists. Which of the following best describes the likely results of this test? a) The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be approximately the same as for the shorter lists. b) The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be significantly more than 10 times greater than for the shorter lists. c) The linear search will now be faster on average than the binary search. d) The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be approximately 10 times greater than for the shorter lists.

d) The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be approximately 10 times greater than for the shorter lists.

Which of the following could be represented by a boolean variable? a) The weight of a truck as recorded at a weigh-station b) The number of tech support requests made in a day c) The direction a car proceeds in at a 4-way intersection d) Whether a guest at a wedding is allergic to peanuts

d) Whether a guest at a wedding is allergic to peanuts

What should replace <missing statement> in the following code be if we want this code to repeat until the variable a is greater than 10? a ← 0 REPEAT UNTIL (<missing statement>) { a ← a + 1 } a) a = 10 b) 10 > a c) a > b d) a > 10

d) a > 10

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? a) 3, 2, 4, 1 b) 3, 4, 1, 2 c) 2, 3, 4, 1 d) 2, 4, 1, 3

a) 3, 2, 4, 1

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? a) odd_counter>2 b) roll_counter>2 c) roll_counter>3 d) odd_counter>3

a) odd_counter>2

Which of the following best describe examples of abstraction Select two answers. a) 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. b) Several developers are working on a program together. In order to complete the work efficiently, they split the program up into several parts, and each work on a section, testing as they proceed. When code is complete they add it to a master program. c) A series of steps for creating a model aeroplane is laid out in a clear order, with specific instructions in great detail for completing each step. d) 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.

a) 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. AND d) 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.

Which of the following best represent examples of abstraction? Select two answers. a) A single command in a high-level programming language actually requires the CPU to perform multiple different operations, each of which would be represented by a different command in machine code. b) A set of crochet instructions describes in full how to complete a certain type of named stitch at the start. Throughout the rest of the instructions, the stitch is referred to by its name without the full instructions being repeated. c) Source code is copied from one program to another so that code to perform a particular operation does not need to be rewritten. D) A courier has to follow a detailed set of precise and detailed instructions to get to her destination. The directions given are followed one at a time in the order they appear.

a) A single command in a high-level programming language actually requires the CPU to perform multiple different operations, each of which would be represented by a different command in machine code. AND b) A set of crochet instructions describes in full how to complete a certain type of named stitch at the start. Throughout the rest of the instructions, the stitch is referred to by its name without the full instructions being repeated.

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. a) Add statements to display the state of the program at various points to try and identify where the error might have occurred. b) Retype each statement in the program again, being extra careful not to make mistakes this time. c) Continue to write code, but look for ways in which the error from this part of the program can be corrected or compensated for. d) Try changing some of the inputs to see under what circumstances the program is not working and what type of error may be occurring.

a) Add statements to display the state of the program at various points to try and identify where the error might have occurred. AND d) 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 illustrates an aspect of efficiency? a) All of these b) Size of program c) Execution time d) Memory usage

a) All of these

Consider the code segment below. Line 1: IF (b ≠ 0) Line 2: { Line 3: a ← a/b Line 4: } Line 5: ELSE Line 6: { Line 7: a ← a*b Line 8: } Which of the following changes will NOT affect the results when the code segment is executed? a) Changing line 7 to a ← 0 b) Changing line 7 to a ← a/b c) Changing line 3 to a ← b d) Changing line 3 to b ← a/b

a) Changing line 7 to a ← 0

Which of the following measures can a programmer take to help ensure that a program produces correct output? Select two answers. a) Develop the program in smaller steps, ensuring each step is correct b) Test multiple inputs on the program c) Calculate the time it takes to run the program d) Find the efficiency of the code

a) Develop the program in smaller steps, ensuring each step is correct AND b) Test multiple inputs on the program

Which of the following statements about variables in programming are true? I. Variables allow a value to be stored for future use II. Once the value of a variable is set it cannot be changed III. The name given to a variable is important for human comprehension, but not for the computer. a) I and III only b) II only c) I, II and III d) I only

a) I and III only

The following lines of code can be used are part of a program which is designed to calculate the total a person will pay for a meal which costs mealTotal before a tax and tip is paid. The final amount should include tax on the original mealTotal at a percentage of taxRate and a tip at a percentage of tipRate on the original mealTotal. I. mealTotal ← mealTotal + tip + tax II. tip ← mealTotal * tipRate / 100 III. tax ← mealTotal * taxRate / 100 IV. DISPLAY mealTotal In which of the following orders could the lines I-IV be placed if the program is to run as intended? Select two answers. a) II, III, I, IV b) III, II, I, IV c) I, II, III, IV d) I, III, II, IV

a) II, III, I, IV AND b) III, II, I, IV

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? Select two answers. a) Naming conventions b) Testing of the code with various inputs c) Adequate and appropriate comments d) Syntax of the language

a) Naming conventions AND C) Adequate and appropriate comments

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 second passengers - the number of passengers on-board the plane destination - 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? a) speed - float, passengers - int, destination - string b) speed - int, passengers - float, destination - string c) speed - float, passengers - string, destination - int d) speed - string, passengers - int, destination - float

a) speed - float, passengers - int, destination - string

A standard deck of playing cards contains 52 cards, with each card being one of four suits: SPADES, HEARTS, CLUBS, and DIAMONDS. Each suit is represented by 13 cards whose values include ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, and KING. Consider the following two algorithms that are intended to find the card representing the "TEN of HEARTS" in a randomly shuffled deck and separate it from the other 51 cards in the deck. Algorithm A Step 1: Pick up the shuffled deck of cards. Step 2: Look at the topmost card in your hands. Step 3: If the card's suit is a HEART, place the card on top of the pile to your left. Step 4: Otherwise, place the card on top of the pile to your right. Step 5: Repeat steps 2 through 4 until you are no longer holding any cards. Step 6: Pick up the cards in the pile to your left. Step 7: Look at the topmost card in your hands. Step 8: If the card's value is a TEN, place all other cards in your hands on top of the pile to your right. Step 9: Otherwise, place the card on top of the pile to your right. Step 10: Repeat steps 7 through 9 until you are holding only one card. Step 11: The only card in your hand is the TEN of HEARTS. Algorithm B Step 1: Pick up the shuffled deck of cards. Step 2: Look at the topmost card in your hands. Step 3: If the card's suit is a HEART or the card's value is a TEN, place all other cards in your hands on top of the pile to your right. Step 4: Otherwise, place the card on top of the pile to your right. Step 5: Repeat steps 2 through 4 until you are holding only one card. Step 6: The only card in your hand is the TEN of HEARTS. a) Only Algorithm A will always work as intended. b) Only Algorithm B will always work as intended. c) Both Algorithm A and Algorithm B will always work as intended. d) Neither Algorithm A nor Algorithm B will ever work as intended.

a) Only Algorithm A will always work as intended.

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? a) Organize the tubs alphabetically by flavor name and use a binary search algorithm to find the customer's requested flavor. b) Organize the tubs according to Olaf's preferences and use a binary search algorithm to find the customer's requested flavor. c) Organize the tubs according to Olaf's preferences and use a sequential search algorithm to find the customer's requested flavor. d) Organize the tubs alphabetically by flavor name and use a sequential search algorithm to find the customer's requested flavor.

a) Organize the tubs alphabetically by flavor name and use a binary search algorithm to find the customer's requested flavor.

Which of the following best describes how a compiled program is run by a computer? a) The binary instructions from the program are loaded into RAM. The CPU reads and executes instructions, storing and accessing data from RAM as needed. b) 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. c) 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 d) The CPU converts instructions into binary. RAM is used to look through and interpret these instructions which are then executed by the CPU.

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

What must you consider when determining the efficiency of an algorithm? Select two choices. a) The length of time required to run the program b) The number of characters used to write the program c) The amount of resources, such as storage, required d) The language in which the program is written

a) The length of time required to run the program AND c) The amount of resources, such as storage, required

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 attempts to move off its grid. b) The robot is in an infinite loop. c) The condition in an IF statement is not met. d) The robot is stuck with nowhere to move.

a) The robot attempts to move off its grid.

Which of the following is the MOST important reason computers use artificial languages over natural language? a) The syntax of artificial languages is explicit and unambiguous b) The syntax of natural languages is easy to translate by computers c) The meaning of different characters and words in an artificial languages is too complicated d) The meaning of different characters and words in an artificial languages is explicit and unambiguous

a) The syntax of artificial languages is explicit and unambiguous

A mathematics professor at Howard University wants his students to write a program to solve complex mathematical problems. The professor asks a programmer to determine the efficiency of each student's algorithm. How can the programmer determine the efficiency of an algorithm? Select two. a) Use mathematical calculations to determine how the number of computations performed by the program will increase as the size of the inputs increase. b) Run the program with many different inputs to determine how much CPU time will be required for algorithm to solve the problem for inputs of different sizes. c) Count the lines of code in the program used to create the algorithm. d) Read the comments in the program to determine whether the purpose of each part of the algorithm is clear or not.

a) Use mathematical calculations to determine how the number of computations performed by the program will increase as the size of the inputs increase. AND b) Run the program with many different inputs to determine how much CPU time will be required for algorithm to solve the problem for inputs of different sizes.

Which of the following could NOT be represented by a boolean variable? a) Whether a traffic light is green, yellow or red b) Whether a light-bulb is on or off c) Whether a store is open or closed d) Whether a moving elevator is moving up or down

a) Whether a traffic light is green, yellow or red

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? a) debugging b) development c) error check d) coding

a) debugging

x ← 0 a ← 3 k ← 4 REPEAT a TIMES { REPEAT k TIMES { x ← x + a } x ← x * (-1) } DISPLAY x a) 9 b) -12 c) -9 d) 12

b) -12

What will be displayed when the code segment below, using the variables a, b, and c, is run? a ← 0 b ← 1 c ← a a ← 2 b ← a DISPLAY (b) DISPLAY (c) a) 0 0 b) 2 0 c) 2 2 d) 1 0

b) 2 0

What would be the final value of the variable third once the following program is complete? first ← 2 second ← 3 third ← first * second second ← third - first first ← first + second + third third ← second * first a) 6 b) 48 c) 33 d) 36

b) 48

Consider the given code using variables a, b, and c. What will be the output of this code? a ← 2 b ← 6 c ← 12 a ← b b ← c DISPLAY(a) DISPLAY(c) a) 12 12 b) 6 12 c) 2 6 d) 2 12

b) 6 12

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) A floating-point value representing the daily rainfall total for July 4th of the previous year b) A list of floating-point values representing the daily rainfall totals for the previous 10 days (June 24th through July 3rd) c) A list of integers representing the previous years in which it has rained in the area on the 4th of July d) A floating-point value representing the highest daily rainfall total over the last 365 days

b) 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 statements comparing low-level programming languages (such as assembly language) and high-level programming languages (such as python or java) are correct? Select two answers. a) A low-level programming language is easier to learn, but some algorithms can only be written using high level programming languages. b) A program written in a low-level language is closer in syntax to the binary code understood by computers than a program written in a high-level language. c) A low-level program can be easily understood and assembled on any hardware, while the use of a compiler means a high-level program is difficult to use on different systems. d) A program written in a high-level language will usually be easier for a person reading the code to understand than one written in a low-level programming language.

b) A program written in a low-level language is closer in syntax to the binary code understood by computers than a program written in a high-level language. AND d) A program written in a high-level language will usually be easier for a person reading the code to understand than one written in a low-level programming language.

Consider the following two algorithms for determining the tallest person in a group. Algorithm A Step 1: Everybody stands and lines up against the wall. Step 2: One person from those who are standing steps forward. Step 3: One person from those who are standing steps forward. Step 4: The shorter of these two people who stepped forward sits down. Step 5: Repeat steps 3 and 4 until only one person is standing. Step 6: The last person standing is the tallest in the group. Algorithm B Step 1: Everybody stands and lines up against the wall. Step 2: Each standing person pairs up with one other standing person. Step 3: The shorter member of each pair sits down. Step 4: Repeat steps 2 and 3 until only one person is standing. Step 5: The last person standing is the tallest in the group. Which of the following statements about these two algorithms is true when applied to a group of 32 people? a) Algorithm A is rarely faster than Algorithm B b) Algorithm A is never faster than Algorithm B c) Algorithm A is usually faster than Algorithm B d) Algorithm A is always faster than Algorithm B

b) Algorithm A is never faster than Algorithm B

Which of the following is a reason for the importance of variables in programming? a) Variables assist in making code more readable. b) All of these c) Variables allow you to change a value used in multiple places in a program easily. d) Variables allow you to store values calculated by the program and access them at a later point in the program.

b) All of these

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? a) Develop all of the major algorithms which will be required for the app by drawing flowchart representations b) Find out from the businesses and potential visitors what information and format they think should be used for the app c) Write thorough documentation explaining how the code for the app works d) Write some sample code to understand how the app might work

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

Subana is writing a program which will calculate the mean average of a set of numbers by adding the numbers and dividing the result by the amount of numbers. She will use a variable, avg, to store this average. Which variable type would be most suitable for avg? a) Boolean b) Floating point (float) c) Integer (int) d) String

b) Floating point (float)

Which of the following would be the most appropriate name for the following procedure (currently named MYSTERY), where number is any number and the procedure CHECK (number) returns true if the number is an integer and false if not? PROCEDURE MYSTERY (number) { IF (number > 0 AND CHECK (number)) { RETURN (true) } RETURN (false) } a) IS_NEG_INT b) IS_POS_INT c) IS_NEG_FLOAT d) IS_POS_FLOAT

b) IS_POS_INT

The algorithm below simulates rolling a regular 6-sided die twice. Consider the goal of determining if the sum of the values of the two rolls is odd or even. 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 What conclusions can be made with regard to what we are trying to determine? Select two answers: a) If the value found in step 6 is 10, 30 or 50 then the sum is odd b) If the last digit of the value found in step 6 is 5, then the sum is odd c) If the value found in step 6 is 10, 20, 30, 40, 50 or 60 then the sum is even d) If the value found in step 6 is not 20, 40, 60, 80, 100 or 120 then the sum is odd

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

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? a) Make a list of bugs which will occur during development and propose ways these could be fixed b) Plan the structure of the program and determine how the major algorithms will work c) Write segments of code in different languages to see which language will be most suitable for the job d) Decide on the schedule for updates and maintenance of the code

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

Which of the following describes the part of a computer which stores instructions and information which has been input to the computer? a) CPU b) RAM c) Binary d) Machine Code

b) RAM

A study of beech trees shows that around 40% of these trees may be susceptible to a newly discovered disease. The computer program below is intended to determine the number of trees which may be susceptible to the disease in a forest containing k beech trees: Line 1: total ← 1 Line 2: repeat k times Line 3: { Line 4: IF () Line 5: { Line 6: total ← total + 1 Line 7: } Line 8: } Line 9: DISPLAY (total) Which of the following could be used to replace <MISSING CONDITION> to ensure the program works as intended? Select two answers. a) RANDOM (1, 5) < 2 b) RANDOM (1, 5) < 3 c) RANDOM (1, 5) ≤ 2 d) RANDOM (1, 5) = 2

b) RANDOM (1, 5) < 3 AND c) RANDOM (1, 5) ≤ 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? a) Binary Code b) Source Code c) RAM d) Machine Code

b) 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? a) Step 1: MOVE_FORWARD ( ) Step 2: MOVE_LEFT ( ) Step 3: MOVE_BACKWARD ( ) Step 4: MOVE_RIGHT ( ) b) 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 ( ) c) Step 1: MOVE_FORWARD ( ) Step 2: ROTATE_RIGHT ( ) Step 3: MOVE_FORWARD ( ) Step 4: ROTATE_RIGHT ( ) Step 5: MOVE_FORWARD ( ) Step 6: ROTATE_RIGHT ( ) Step 7: MOVE_FORWARD ( ) d) Step 1: MOVE_FORWARD ( ) Step 2: TURN_LEFT ( ) Step 3: Repeat steps 1 and 2 four more times

b) 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 ( )

Rhys is creating a program which stores customer records. One variable used in the program stores the first initial of a customer's name. Which of the following data-types could be used to store this data? Select two answers. a) Boolean b) String c) Character d) Integer

b) String AND c) Character

Consider the following code: n ← 4 x ← -2.5 I F(n < 3) { DISPLAY("Team A") } ELSE { IF(n < 2) { DISPLAY("Team B") } ELSE { IF(x > -2) { DISPLAY("Team C") } ELSE { DISPLAY("Team D") } } } Which of the following is the output of the code? a) Team B b) Team D c) Team A d) Team C

b) Team D

Consider the following algorithm which uses an integer variable n. 1. Double the value of n 2. Add 34 to the answer 3. Round the answer to the nearest ten 4. Sum the digits of the answer 5. Display the final answer Which of the following statements best describes the predictability of the results when this algorithm is run on a computer? a) The answer displayed by the algorithm can be predicted for some values of n, but not for others. b) The answer displayed by the algorithm for any known value of n can always be predicted. c) It is impossible to predict the value of the answer displayed, even if the value of n is known. d) The algorithm always displays the same answer, regardless of the value of n.

b) 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? Select two answers. a) The program will run faster. b) The program will be easier for others to debug. c) The program will be easier to read. d) The program will use less resources.

b) The program will be easier for others to debug. AND c) The program will be easier to read.

Which of the following describes good practice when naming variables in code? Select two answers. a) Use names which contain as few different characters to aid the compiler and shorten compile times b) Use names which describe what each variable represents to make code easier to understand c) Use names which show in what order the variables were introduced to make it easier to find the value of a variable d) Use concise names to avoid typos and keep code tidier

b) Use names which describe what each variable represents to make code easier to understand AND d) Use concise names to avoid typos and keep code tidier

Which of the following is the best example of a heuristic approach to solving a problem? a) Using a graduated cylinder to measure the number of milliliters needed to mix a certain acid needed for an experiment. b) Using your thumb and forefinger in order to add a pinch of salt to a meal because the recipe that your grandma has written on an index card says, "Add some salt". c) Using a tape measure to find the length of a span between two beams so that you can cut to length a third beam needed to create a roofing section on a house. d) Using a scientific calculator in order to find the hypotenuse of a triangle using the Pythagorean Theorem.

b) Using your thumb and forefinger in order to add a pinch of salt to a meal because the recipe that your grandma has written on an index card says, "Add some salt".

Under which of the following conditions is it most beneficial to use a heuristic approach to solve a problem? a) When the problem cannot be accurately solved in a reasonable time and an exact solution is needed. b) When the problem cannot be accurately solved in a reasonable time and an approximate solution is acceptable. c) When the problem can be accurately solved in a reasonable time and an approximate solution is acceptable. d) When the problem can be accurately solved in a reasonable time and an exact solution is needed.

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

Marta is writing a program for a home-automation system. Three of the variables in her program are as follows: light - A variable which determines whether the lights in a room are switched on or off temp - A variable which records the temperature of the room to the nearest whole degree Fahrenheit name - A variable which records the name the user has set for the room (e.g. "kitchen") Which of the following correctly describes the types which would be best used for each of these variables? a) light - string, temp - integer, name - boolean b) light - boolean, temp - integer, name - string c) light - integer, temp - boolean, name - string d) light - boolean, temp - string, name - integer

b) light - boolean, temp - integer, name - string

Which of the following best describes how abstraction makes code written in higher-level programming languages easier for humans to parse? a) Abstractions used in higher-level languages make the code closer to the actual individual operations performed by the CPU b) Abstractions used in higher-level languages make them almost identical to a natural language which would be spoken by humans. c) Abstractions used in higher-level languages mean what a command does is easier to understand without needing to parse all the individual operations performed by the CPU. d) Abstractions used in higher-level languages remove any potential ambiguity from the code.

c) Abstractions used in higher-level languages mean what a command does is easier to understand without needing to parse all the individual operations performed by the CPU.

Which of the following is an advantage that block-based programming languages (e.g. Scratch) have over text-based programming languages (e.g. Processing)? a) Block-based programming languages offer programmers more detailed control over lower-level functionality when writing a program. b) Block-based programming languages allow programmers to write programs in English and other natural languages. c) Block-based programming languages do not require the programmer to worry about syntax, capitalization, or punctuation. d) Programs written in block-based programming languages do not require debugging.

c) Block-based programming languages do not require the programmer to worry about syntax, capitalization, or punctuation.

Which of the following best describes "compilation" in reference to computer science? a) Algorithms which have been planned, for example using flow-charts, are written in code. b) Instructions are repeated a set number of times, or until some specified objective is completed. c) Code in a high-level language is converted to low-level instructions which can be interpreted and run by the CPU. d) Memory is set aside to store variables and instructions so that a program can be executed.

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

Computers may be programmed to play logic games such as chess and go. These games have an incredibly large number of possible move sequences which may be made. Which of the following describes a good strategy and accompanying rationale for creating an algorithm which a computer can use to play these games? a) Develop an algorithm which uses heuristics because this will run much quicker than evaluating every possible move, but will still result in the optimum move being made every time. b) Develop an algorithm which will evaluate all possible moves because processor speeds are fast enough that there will be little noticeable delay in doing this. c) Develop an algorithm which uses heuristics because this will be able to provide reasonable solutions, and evaluating every possible move will take an impractical amount of time. d) Develop an algorithm which will evaluate all possible moves because heuristics cannot perform well enough to ever defeat a proficient human player.

c) Develop an algorithm which uses heuristics because this will be able to provide reasonable solutions, and evaluating every possible move will take an impractical amount of time.

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of goats and sheep throughout the text. Consider the programmer's goal of changing all occurrences of goats to sheep and all occurrences of sheep to goats. The programmer will use the fact that the word foxes does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish this? a) First, change all occurrences of goats to sheep, and then change all occurrences of sheep to goats. b) First, change all occurrences of goats to sheep, then change all occurrences of sheep to foxes, and then change all occurrences of foxes to goats. c) First, change all occurrences of goats to foxes, then change all occurrences of sheep to goats, and then change all occurrences of foxes to sheep. d) First, change all occurrences of goats to foxes, then change all occurrences of foxes to sheep, and then change all occurrences of sheep to goats.

c) First, change all occurrences of goats to foxes, then change all occurrences of sheep to goats, and then change all occurrences of foxes to sheep.

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? a) Select the most appropriate language for the application b) Sit side-by side throughout the debugging process c) Give some examples of user input and what the result should look like d) Write some sample code to show the programmer exactly what he wants

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

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 a) I and II only b) I and III only c) I, II, and III d) II and III only

c) I, II, and III

Which of the following CollegeBoard AP Computer Science Principles Pseudocode commands is used to record something typed by a user of the program so that it can be used in the program? a) a MOD b b) RANDOM (a, b) c) INPUT () d) DISPLAY (expression)

c) INPUT ()

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. a) Include comments detailing previous, unsuccessful coding attempts. b) Choose meaningful names for all variables and procedures. c) Include comments detailing the purpose and behavior of variables and procedures. d) Repeat blocks of code to emphasize their importance in the process.

c) Include comments detailing the purpose and behavior of variables and procedures.

Consider the following two implementations of the same algorithm, each written in a different language. 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? a) The algorithms in both languages are ambiguous because they do not specify the actual values of the seven daily rainfall totals. b) Language A is ambiguous because it is unclear what sun, mon, tue, wed, thu, fri, and sat refer to in context with the problem. c) Language B is ambiguous because the process of "average" is not explained well d) Neither of these languages is clear enough that a programmer could write a correct solution in a high-level programming language.

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

The following algorithm is proposed for the task of baking a cake, and is presented along with a list of ingredients. Add some ingredients from the list to a bowl Stir Add other ingredients to a bowl Stir Put in a tin in the oven Take out tin from oven Which of the following correctly describes an issue with the way the instructions in this algorithm is presented? a) The sequencing of the instructions is unclear b) The instructions do not contain any selection or iteration statements c) The instructions lack descriptive qualifiers d) The instructions lack imperative statements.

c) The instructions lack descriptive qualifiers

Consider the following code: IF (n > 0) { DISPLAY ("The number is positive.") } ELSE { DISPLAY ("The number is not positive.") } What will be output by this code if the number n is zero? a) Both of the above b) The number is positive. c) The number is not positive. d) Neither of the above

c) The number is not positive.

A program has been developed to compute the sum of all elements with a value greater than 10 in a list of integers. Which of the following statements best describes how iteration may be used to in the program in this example? A) The program will execute the commands for finding and adding the numbers in the order in which they appear in the program. b) The program will initiate a variable at the beginning and return the value of that variable at the end. c) The program will repeat the execution of a block of commands which test the value of an item and add it to a running total (if it is greater than 10) for each value in the list. d) The program will only execute a command which adds a value in the list to a running total if that value is greater than 10.

c) The program will repeat the execution of a block of commands which test the value of an item and add it to a running total (if it is greater than 10) for each value in the list.

Which of the following best describes high-level computing languages? a) They are extremely difficult for humans to read and understand b) They are very easy for machines to understand and parse c) They are not very ambiguous d) They evolve naturally over time

c) They are not very ambiguous

Erin has written a program which presents a user with multiple-choice quiz questions to answer and calculates a percent score based on the number the user got right or wrong. Each question has 5 possible answers, and scores presented are from 0 to 100 percent inclusive. Which of the following could be represented by a boolean variable? a) The percent score of the user b) The number of questions in the quiz. c) Whether a user got a specific question right or not d) The correct answer choice for a particular question.

c) Whether a user got a specific question right or not

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? a)string b) int c) float d) bool

c) float

Consider the following code: REPEAT UNTIL (x mod 2 = 1) { x ← x + 3 } Assume that x is initially 6. How many times will the loop iterate? a) 2 b) 0 c) 3 d) 1

d) 1

Which of the following is a valid reason for giving variables meaningful names in a program? a) The compiler will be able to parse the code faster since it will know the purpose of each variable. b) 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. c) The code will run with fewer errors since the CPU can interpret what the variable represents from its name. d) A programmer will find it easier to read and understand the code since they will know what the variables represent.

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

Which is NOT true about comments in programs? a) Commenting about program components helps in developing and maintaining programs. b) Commenting helps programmers develop and maintain programs to efficiently solve problems. c) Commenting helps while working collaboratively in programming environments. d) All published programs have their comments available.

d) All published programs have their comments available.

Moore's Law describes the rate at which the number of transistors on a single chip doubles over time. Which of the following assumptions CANNOT be inferred as a direct consequence of this rate of doubling? a) Five years from now, computer programs will be able to solve complex problems faster than today's computer programs. b) Five years from now, top-of-the-line computers will have faster processors (CPUs) than today's top-of-the-line computers. c) Five years from now, electronic components can be made smaller than today's equivalent electronic components. d) Five years from now, web pages will require less memory (RAM) than today's web pages.

d) Five years from now, web pages will require less memory (RAM) than today's web pages.

Which of the following statements about high-level programming languages when compared to low-level programming languages is true? a) High-level programming languages provide programmers with less abstractions and are more difficult for people to read b) High-level programming languages provide programmers with more abstractions but are more difficult for people to read c) High-level programming languages provide programmers with less abstractions but are easier for people to read d) High-level programming languages provide programmers with more abstractions and are easier for people to read

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

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 II. Following the instructions in the algorithm will always result in the same outputs, regardless of any inputs III. The instructions in the algorithm contain all necessary information to be implemented a) I only b) I, II and III c) II and III only d) I and III only

d) I and III only

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? a) Idea→algorithm→write code→execute code→maintain→debug b) Idea→write code→algorithm→execute code→debug→maintain c) Idea→algorithm→write code→debug→execute code→maintain d) Idea→algorithm→write code→execute code→debug→maintain

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

Which of the following best describes the result of running the program below? number ← RANDOM (1, 6) REPEAT UNTIL number > 100 { number ← number * 2 } IF (number = 128) { DISPLAY (true) } ELSE { DISPLAY (false) } a) If number is originally even, then the program will display true. b) If number is originally odd, then the program will display true. c) If number is a 2, 4 or 5, then the program will display true. d) If number is a 1, 2 or 4, then the program will display true.

d) If number is a 1, 2 or 4, then the program will display true.

Which of the following is an important step to take before beginning to write the code for a program? a) Plan an update and maintenance schedule for the program b) Write on paper or a whiteboard all the code you intend to type c) Randomly generate the variable names to be used in the program d) Plan the logic and anticipated input/output of the code

d) Plan the logic and anticipated input/output of the code

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 a) Natural language b) Low-level language c) High-level language d) Pseudocode

d) Pseudocode

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? a) RANDOM(a,b) - 2 b) RANDOM(a,b) + 1 c) RANDOM(a,b) + 2 d) RANDOM(a,b) * 2

d) RANDOM(a,b) * 2

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. a) Strategy I only b) Strategy I and Strategy II will both allow the students to create a quality application c) Neither Strategy I nor Strategy II will allow the students to create a quality application d) Strategy II only

d) Strategy II only

Microsoft Excel® is a spreadsheet program that can be used for computing the average of a list of values in cells A1 through A20 with a command such as =AVERAGE(A1:A20). After the user initiates this command, the command disappears and the average (or mean) of the list of numbers appears. Why is this an abstraction? a) There is an equal sign present in the command. b) There is math being used in order to calculate the average. c) There are steps that are followed in order to complete the calculations. d) The average can be viewed without knowing the process of how the average was computed.

d) The average can be viewed without knowing the process of how the average was computed.

Which of the following will cause an algorithm to fall into an infinite loop? a) The output operations are missing b) The algorithm uses more than one loop c) The input operations are missing d) The condition of the loop never becomes false

d) The condition of the loop never becomes false

Which of the following best describes why the development process by which computer programs are created is described as "iterative"? a) Evaluation and testing may take place throughout the process and not just at the end. b) The steps in the process must be strictly followed one after another. c) The process begins with planning and design phases before any of the implementation begins. d) The process is a cycle, with results from one run of the cycle feeding into the next.

d) The process is a cycle, with results from one run of the cycle feeding into the next.

In a flowchart, a typical decision symbol has what type of output? a) text b) numerical c) None of these d) boolean (true/false)

d) boolean (true/false)


Ensembles d'études connexes

English File Beginner Common verb phrases 2

View Set

Intro to Network: Home and Peer to Peer (NCTI)

View Set

70-742 Lesson 9 Questions and Key Terms (2012 Questions as well)

View Set

ANTH 202 - Most Missed Exam Questions

View Set