Ap computer science Exam review all questions from unit 1-3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What would be the final value of the variable third once the following program is complete?

48

Consider the following code segment: If the variables onTime and absent both have the value false, what is displayed as a result of running the code segment?

Better late than never.

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?

Floating point (float)

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?

Input ( )

The following code segment is intended to display the difference in the sums of two non-empty lists of integers, list1 and list2. Which of the following changes will reduce the number of operations performed by the program without making it incorrect?

Interchanging line 11 and line 12

Sam's password is known to be formed of 3 decimal digits (0-9) in a given order. Karren and Larry are attempting to determine Sam's password by testing all possible combinations. If they are only able to try 10 combinations every day, how many days would it take to try all the possible combinations?

100

In the program below, x is an integer between 5 and 10 inclusive. What is the maximum possible value of answer after running the program?

20

Consider the following block of code: Which two of the following values are more likely to be displayed than the other two values listed when the this block of code is run? Select two answers

20 5

A large company uses 10-bit binary numbers to identify its employee records. It plans to change this system to use 12-bit binary numbers instead. Which of the following statements best describes the effects of this change?

4 times the number of individual records can potentially be stored.

Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?

41

The code segments for making a Scratch program which simulates a conversation between the user and a sprite on-screen are given below. Which of the following orders is most suitable if the program is to run without errors and produce the most realistic appearing conversation?

5-3-1-4-2

Consider the following code segment: What values, when inputted by the user, of A, B, and C will cause the code to display "Invalid Input"?

A = -5 B = 0 C = 0

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 list of floating-point values representing the daily rainfall totals for the previous 10 days (June 24th through July 3rd)

Which of the following scenarios will likely result in an overflow error?

A program which stores positive integers using 4 bits attempts to add the (decimal) integers 7 and 9

Which of the following best represent examples of abstraction? Select two answers

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

Refer to the following code segment: The procedure check is supposed to display a statement correctly comparing the size of the two provided numbers, value1 and value2. Which of the following changes to the code would be the best choice to make the procedure work as intended?

Add another IF / ELSE block, nested in the ELSE section

The following two algorithms are designed to find the number of integers on a list which have a value greater than 5. Algorithm I:Create a variable count and set this to zero. For each value on the list, check whether it is greater than 5. If it is, then add 1 to the value of count. When the end of the list is reached display the value of count.Algorithm II:Create a variable count and set this to the number of items on the list. For each value on the list, check whether it is smaller than 5. If it is, then subtract 1 from the value of count. When the end of the list is reached display the value of count. Which of the following statements correctly demonstrates that the two algorithms are NOT equivalent?

Algorithm I will correctly display the number of integers greater than 5 on the list [4, 10, 5, 1], but Algorithm II will not.

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?

Algorithms

Which of the following could be considered part of the beginning "state" of a Scratch program?

All of the options listed

Which of the following algorithms require both selection and iteration? Select two answers:

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

A certain programming language uses 4-bit binary sequences to represent nonnegative integers. For example, the binary sequence 0101 represents the corresponding decimal value 5. Using this programming language, a programmer attempts to add the decimal values 14 and 15 and assign the sum to the variable total. Which of the following best describes the result of this operation?

An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15.

Consider the block of code below: if x<10 missing boolean operator x>0 display true What would be the most appropriate substitute for the missing Boolean Operator if the intention is to display "True" for only values of x between, but not equal to values of 0 and 10?

And

The following question uses a robot and a grid of squares. The robot is represented as a triangle, which is initially in the bottom left square of the grid and facing right. Consider the following code segment, which moves the robot on the grid: Which of the following shows the location of the robot after running the code segment?

Arrow in the middle of the grid

Which of the following is an advantage that block-based programming languages (e.g. Scratch) have over text-based programming languages (e.g. Processing)?

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

Imagine you are programming a simple calculator using Scratch and you want to create a feature which adds a fixed number to an existing variable named "balance". Which of the blocks below will be the most appropriate to use for this feature?

Change balance by

A company that develops educational software wants to assemble a collaborative team of developers from a variety of professional and cultural backgrounds. Which of the following is NOT considered a benefit of assembling such a team? Responses

Collaboration that includes diverse backgrounds and perspectives can eliminate the need for software testing

Binary 1011 Binary 1101 Decimal 5 Decimal 12 Which of the following lists the values in order from least to greatest?

Decimal 5, binary 1011, decimal 12, binary 1101

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?

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

A video game character can face toward one of four directions: north, south, east, and west. Each direction is stored in memory as a sequence of four bits. A new version of the game is created in which the character can face toward one of eight directions, adding northwest, northeast, southwest, and southeast to the original four possibilities. Which of the following statements is true about how the eight directions must be stored in memory?

Four bits are enough to store the eight directions

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?

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

Given the following code segment, what would be displayed if agewere initialized with a value of 18? If age<18 or age>65 display group 1 else display group 2

Group 2

Three students in different locations are collaborating on the development of an application. Which of the following strategies is LEAST likely to facilitate collaboration among the students?

Having all three students write code independently and then having one student combine the code into a program

Which of the following statements about high-level programming languages when compared to low-level programming languages is true?

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

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? No algorithm has yet been developed which would solve this problem, but it is possible one may be developed in the future. 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. It is impossible to develop an algorithm which would solve this problem.

I, II, and III

Which of the following are true statements about the data that can be represented using binary sequences? Binary sequences can be used to represent strings of characters. Binary sequences can be used to represent colors. Binary sequences can be used to represent audio recordings

I, II, and III

From the following blocks, a code segment can be formed which will swap the values of the variables a and b. Which of the following gives a correct, ordered set of instructions which will create a code segment swapping the initial values of a and b?

IV, I, II

The volume of a rectangular prism is calculated by multiplying its length (l), width (w) and height (h). What could be substituted into the section of the code below marked < missing code > that would accurately calculate the volume based on the user input of l, w and h?

L*W*H

A large office building has an elevator that carries occupants between any of the building's 10 floors. The basement is referred to as "Level 0" while the topmost floor is "Level 9." The software for the elevator uses a variable, called level, to track the floor number of the elevator's current position. When a person presses a button requesting the elevator to rise to a higher floor, the following is invoked: What is displayed if the elevator is currently on the 7th floor (level = 7) and the person on the elevator presses a button labeled "up 3 floors" which causes the variable floors to be set to 3. What will be displayed when the code above runs?

Level 8 Level 9 Cannot go up. Level 9

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?

Low-level programming language

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

Naming conventions Adequate and appropriate comments

The list mine is initialized with the values -- green, red, blue, purple, yellow, black -- and the list yours is initialized with the values -- green, red, black, blue. What will be displayed after the following code segment runs?

None of the messages listed are displayed: Partway through, an error message is produced and the program terminates.

Consider the following code segment: Which of the following best describes the result of running the code segment?

Nothing is displayed; the program results in an infinite loop

The program below is intended to find and display the total when all the unique numbers on the list of integers numbers are summed (e.g. if a list contains a number twice it will only be added to the total once). The program makes use of a procedure named IsFirstOccurence. Which of the following definitions of this procedure would cause the program to function as intended?

PROCEDURE IsFirstOccurence(list, pos) { index ← 1 REPEAT UNTIL (index = pos) { IF (list [index] = list [pos]) { RETURN (false) } index ← index + 1 } RETURN (true) }

Which of the following is an important step to take before beginning to write the code for a program?

Plan the logic and anticipated input/output of the code

Peter wrote the following code in scratch to make a sprite perform a series of coordinated moves, forming a "dance routine." The code will be used for a competition, and Peter does not want to reveal the moves performed by the sprite in his program. Currently the path taken by the sprite is traced on the screen. Which of the following changes to the code will change this and allow Peter to keep the path taken by his sprite hidden?

Removing the pen down block

Tom created the following code segments in Scratch, which are intended to create a short piece of music between them.When the green flag is clicked, each of the three scripts is intended to run in turn, however, due to a mistake in the code, this does not happen. Which of the following changes could Tom make to ensure that all three of the scripts run as intended?

Replace the block broadcast sound 3 with the block broadcast sound 2

The incomplete code displayed below is for a simple "Guess the Number" game in which the user inputs values and is displayed statements about the relationship of their input to a randomly chosen secret number until they correctly input that number. The condition for the first IF block in the code is missing. Based on the intended purpose of the code, which of the following blocks would be most appropriate as the missing condition?

Secret number<guess

Consider the following code segment that allows a customer to request their preferred beverage and size of beverage (ounces). What is displayed if the user enters "16" and then "coffee" when the program runs?

Short coffee

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?

Source Code

Consider constructing an algorithm for a robot that can only perform the following three predefined operations. 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?

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

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.

Strategy II only

ASCII is a character-encoding scheme that uses a numeric value to represent each character. For example, the uppercase letter "G" is represented by the decimal (base 10) value 71. A partial list of characters and their corresponding ASCII values are shown in the table below. ASCII characters can also be represented by binary numbers. According to ASCII character encoding, which of the following letters is represented by the binary (base 2) number 1010100?

T

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?

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 is not true about digitizing physical media?

The digital version is always equally as good as the physical one in terms of quality.

Given a list of integers, sequence, and an integer, value, which of the following best describes what the code segment does?

The number of items in sequence that are less than value is displayed

Consider the 4-bit binary numbers 0011, 0110, and 1111. Which of the following decimal values is NOT equal to one of these binary numbers?

The position of a runner in a race is a type of analog data. The runner's position is tracked using sensors. Which of the following best describes how the position of the runner is represented digitally?

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.

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

Consider the following program, which is intended to display the number of items on a list which are not equal to an item called stopValue. Which of the following best describes the behavior of the program?

The program displays the number of words not equal to stopValue subtracted from the number of words equal to stopValue

Consider the following code segment which makes use of the list deck and the positive integer i: Which of the following could be displayed when this segment of code is executed, assuming that the block sort list will sort the parameter list in alphabetical order from A to Z, and the user responds to each input?

Tim Tim Tim

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?

Time_left

Lists are widely used in programming, however, lists are not necessary for all programming tasks. In which of the following situations would you be least likely to need to use a list in a program?

Tracking the last song that played in a game, so that people playing the game don't hear the same song twice in a row.

The elements of the list "months" are given below: What is the output of the following block? (Hint: think about case sensitivity.)

True

A company that develops mobile applications wants to involve users in the software development process. Which of the following best explains the benefit in having users participate?

Users can provide feedback that can be used to incorporate a variety of perspectives into the software.

Below is the International Morse Code, where each letter is made up of a unique combination of dots and dashes. This code is an example of what type of encoding?

Variable width

Which of the following could be represented by a boolean variable?

Whether a guest at a wedding is allergic to peanuts

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

Which color is currently being shown by a traffic light

What list will be displayed when the following code segment is run?

banana, banana, apple, banana, grape, kiwi, orange

Consider the code below. Which of the following best describes the conditions which must be satisfied by the user-inputted values of x and y if the program is to display Right Right when run?

x must be 0 and y must be a positive number


Set pelajaran terkait

Hinkle, Ch. 28: Assessment of Hematologic Function & Treatment Modalities

View Set

Criminal Law Multiple Choice Questions

View Set

Chapter 11 - Strings - Character Arrays

View Set

Chapter 4. Networking—It's Always Who You Know

View Set

Business Info Systems: Pivot Tables

View Set

Accounting Ch. 5 - Balance Sheets

View Set

Wk 4 - Practice: Ch. 7, Business Strategy: Innovation [due Day 5]

View Set