Unit 1 Review APCSP

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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

(X > -5) AND (X ≤ 20) This is correct. The expression in the question is satisfied whenever (1) the value of x is between 0 and 20 (including 20), or (2) the value of X is between −5 and 15, or both conditions (1) and (2) are satisfied. For every value of X greater than −5 and not larger than 20, at least one of the conditions (1) or (2) is satisfied, and for every value of X not in this range, neither of the conditions (1) or (2) is satisfied. Therefore any value of x which satisfies (X &gt; -5) AND (X ≤ 20) also satisfies the expression in the question, and any value of x which does not satisfy (X &gt; -5) AND (X ≤ 20) does not satisfy the expression in the question. This must mean that the two expressions are equivalent.

Consider the following code segment, which is attached to a sprite in a Scratch program: (refer to image) Suppose this Scratch program is run, and the user types 3 in response to the first question, and 5 in response to the second question. What number does the sprite say at the end of this script? a) No answer text provided. b) 10 c) 8 d) 6

10 This is correct. The first user input of 3 is stored as answer, and the value of num is then set to the same value as answer, so this is also 3. The second user input of 5 is then stored as answer, replacing the old value of 3, and once again num is changed to the same value as answer, 5. The sprite then says the sum of num and answer, and as both of these are equal to 5, this is 5 + 5 = 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 inputs2. Designing an algorithm to tackle the central problem the program hopes to solve3. Considering what outputs a program solving the problem might produce and what inputs it may require to do this4. 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) 2, 4, 1, 3 b) 3, 2, 4, 1 c) 3, 4, 1, 2 d) 2, 3, 4, 1

3, 2, 4, 1 This is correct. Action number 3 involves an initial idea for the program in terms of what it might do, action 2 involves the development of a logical process by which this could happen, action 4 involves implementing this project in code, and action 1 is testing that this code works as intended.

Which of the following best describe examples of abstraction Select two answers. a) 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. b) 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. c) 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. 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 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. 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. This is correct. The constant π, which has an infinite decimal expansion, is represented by a simple variable name of pi. This is therefore an example of abstraction, where a complex system is replaced with a simplified representation. This is correct. Each chord is actually made up of several different notes, but is represented by just one or two characters. This is therefore an example of abstraction, where a complex system is replaced with a simplified representation.

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 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. b) A low-level programming language is easier to learn, but some algorithms can only be written using high level programming languages. 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.

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. 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. This is correct. In contrast to high-level languages, the commands and syntax of low level languages, such as assembly language, closely reflect a machine or binary code understood by computers. This is correct. One implication of this is that it is harder for a human to read and understand a low-level language than a high-level language, which was designed for humans to use to program efficiently.

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

A programmer will find it easier to read and understand the code since they will know what the variables represent. This is correct. Naming variables is something which is exclusively done for the benefit of humans reading source code. By picking a suitably meaningful name, the purpose and function of a variable can be quickly determined when reading a statement in which it is contained, meaning a person reading the code does not have to look through many other lines of code to determine what a single statement does.

variable

A variable is an abstraction inside a program that can hold a value

Consider the following statement which refers to the block (move 10 steps) When you execute this block in Scratch, your computer is actually doing several things: retrieving values from memory representing the direction and position of the sprite, performing an algorithm to update these values, and changing the display in the window to match the updated state of the program. All of these actions are represented by just one single block. Which of the following terms names the phenomenon which is best described by this statement? a) Compilation b) Abstraction c) Iteration d) Sequencing

Abstraction This is correct. Abstraction refers to the process by which a complicated system is replaced by a simplified representation. This is occurring in the scenario described, where the single block represents a series of more complex tasks.

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 mean what a command does is easier to understand without needing to parse all the 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 make the code closer to the actual individual operations performed by the CPU d) Abstractions used in higher-level languages remove any potential ambiguity from the code.

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. This is correct. Abstraction replaces a complex system with a simplified representation. In this case a complicated sequence of operations being performed by the CPU is replaced with a simplified representation which is more easily understandable to a human.

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

All of these This is correct. Variables are an important part of programming for all of the reasons described above: if the same number is used multiple times in a program it is often best to use a variable, as there is no need to go through and change each appearance of this number when changing the value. Additionally a descriptively named variable can enable a human reading the code to understand what is being computed at each stage and why. Variables can also have new values written to them, meaning they can store a value created part way through a program for later use.

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

Boolean This is correct. A boolean can take a true or false value, so is useful for storing variables which can only take 2 possible values.

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) Character c) String d) Integer

Character String This is correct. A character stores a single letter, number or symbol, and therefore is ideally suited to storing a single letter variable. This is correct. A string variable stores a sequence of letters, numbers and symbols, and could therefore be used to store a single letter if required.

Which of the below options would be the best set of instructions to give for a program designed in Scratch? a) Ready, set, RUN!!!!! Use your skills and intelligence to weave your way through the maze, avoiding obstacles and prove that you've got what it takes to survive! b) Click on the GREEN flag. Once the game starts, use the arrow keys to navigate your way through the maze. In your travels, collect the "hearts" for more lives and avoid being eaten by zombies. c) Make your way through the maze! Avoid the brain-eating zombies and be sure to collect the "hearts" for extra lives. Good Luck! d) Dodge zombies, gain lives, all while trying to make it through the maze! Click start to begin your exciting adventure.

Click on the GREEN flag. Once the game starts, use the arrow keys to navigate your way through the maze. In your travels, collect the "hearts" for more lives and avoid being eaten by zombies. This is correct. These instructions are the only set which contain specific instructions for how the user interacts with the game when it is running (using the arrow keys). It also explains how to start the game by using the green flag: a common method used in Scratch to begin a program.

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

Code in a high-level language is converted to low-level instructions which can be interpreted and run by the CPU. This is correct. The CPU of a computer only understands its own machine code, therefore any program written in a high-level language must be compiled (using a program called a compiler) to a set of equivalent instructions in machine code which the CPU can run.

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

Code written using high level languages is guaranteed to be ambiguous Any particular algorithm will be written in the same way regardless of which high level programming language is used This is correct. This is a false statement as programming languages are unambiguous (when properly documented), meaning a program only has one possible way of being interpreted. This is correct. This is both the syntax and semantics of different high level languages can be quite different. Therefore while it is usually possible to write an algorithm in many different languages, the way in which it is written may be quite different.

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) Coding b) Development c) Error check d) Debugging

Debugging

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

I and III only This is correct. The instructions in an algorithm are followed in a logical order, determined by sequencing, selection and iteration. The instructions should be possible to execute from the information given in any algorithm.

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

I and III only This is correct. The use of a variable is primarily to store values which can be used later. It is important to name variables so that code is comprehensible to people reading it (including the original programmer) and its purpose and function can be quickly determined. Despite this, it makes no difference to the running of the program by the computer what variable names are used.

Greg is designing a Scratch game in which the player moves a sprite by pressing the arrow keys. Greg writes the following scripts for the sprite: (refer to image) I. If Greg wants to change the default speed the sprite moves at he only needs to edit one block rather than 4II. It is easy for Greg to add functionality to the program to change the speed of the sprite based on the gameplay (e.g. slowing the sprite's speed when injured)III. It is clearer what the number used in the four movement scripts describes in the game. a) I and II only b) III only c) I only I, II and III

I, II and III This is correct. By replacing the number with the variable speed, it is clear that this number relates to how fast the sprite moves across the screen when the key is pressed. By changing the block (set speed to 10), Greg can change the default speed. To do that with his original script he would need to change all four (move 10 steps) blocks. To change the speed based on an action in the program he can add a block to set or change the speed variable to another script, and it will increase the speed of the sprite. He could not do this without making changes if he were to use his original script.

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 situationIII. A recipe for baking a cake with detailed numbered steps to follow a) I and II only b) I and III only c) II and III only d) I, II and III

I, II and III This is correct. Each of the problems described (assembling a piece of furniture, dealing with an emergency situation and baking a cake) are solved through a set of logically ordered, precise instructions. These solutions can therefore be thought of as being algorithmic in nature.

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

II only This is correct. The order of instructions is clear, as is which parts should be used for each instruction. Imperative statements (e.g. attach, place together, fasten to) however are required in order for someone following the algorithm to understand what actions they actually have to perform with the parts listed.

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→debug→maintain 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→maintain→debug

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

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 last digit of the value found in step 6 is 5, then the sum is odd b) If the value found in step 6 is 10, 30 or 50 then the sum is odd c) If the value found in step 6 is not 20, 40, 60, 80, 100 or 120 then the sum is odd d) If the value found in step 6 is 10, 20, 30, 40, 50 or 60 then the sum is even

If the last digit of the value found in step 6 is 5, then the sum is odd If the value found in step 6 is 10, 20, 30, 40, 50 or 60 then the sum is even This is correct. Step 4 adds the two randomly generated numbers from steps 1 to 3 together to give a sum. As each of the numbers was between 1 and 6 inclusive, the sum will be an integer from 2 to 12 inclusive. Steps 5 and 6 cause that sum to be multiplied by 10 and then divided by 2: the cumulative result of these steps is that the sum is multiplied by 5. Therefore if the sum was one of the possible odd numbers (3, 5, 7, 9, 11), then the output at step 6 will be one of the following: 15, 25, 35, 45, 55, all of which have a last digit of 5. This is correct. Step 4 adds the two randomly generated numbers from steps 1 to 3 together to give a sum. As each of the numbers was between 1 and 6 inclusive, the sum will be an integer from 2 to 12 inclusive. Steps 5 and 6 cause that sum to be multiplied by 10 and then divided by 2: the cumulative result of these steps is that the sum is multiplied by 5. Therefore if the sum was one of the possible even numbers (2, 4, 6, 8, 10 , 12), then the output at step 6 will be one of the following: 10, 20, 30, 40, 50, 60.

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) Language A is ambiguous because it is unclear what sun, mon, tue, wed, thu, fri, and sat refer to in context with the problem. b) The algorithms in both languages are ambiguous because they do not specify the actual values of the seven daily rainfall totals. 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.

Language B is ambiguous because the process of "average" is not explained well This is correct. The terminology "average them together" is quite ambiguous, especially since more than one type of "average" exists. This might make it difficult for a programmer to write code that gives the result desired by the person writing this statement.

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

Plan the structure of the program and determine how the major algorithms will work This is correct. When the initial planning and ideas phase of the development cycle is complete, the next step should be to consider the overall design of the program and how it will implement the desired functionality.

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

RAM This is correct. RAM stands for Random Access Memory. This memory is used to store information short-term, such as instructions to be executed and values to be used in the execution of these instructions.

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

RANDOM(a,b) * 2 This is correct. The command * typically represents multiplication. Therefore the command RANDOM(a,b) * 2 generates a random integer between a and b inclusive, then multiplies this integer by 2. This will always result in an even number answer.

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 could successfully cause the robot to trace out a "T"-shaped path as drawn above? a) Step 1: MOVE_FORWARD ( ) Step 2: ROTATE_LEFT ( ) Step 3: ROTATE_LEFT ( ) Step 4: MOVE_FORWARD ( ) Step 5: ROTATE_RIGHT ( ) Step 6: MOVE_FORWARD ( ) b) Step 1: MOVE_FORWARD ( ) Step 2: MOVE_FORWARD ( ) Step 3: ROTATE_LEFT ( ) Step 4: ROTATE_LEFT ( ) Step 5: MOVE_FORWARD ( ) Step 6: ROTATE_RIGHT ( ) Step 7: MOVE_FORWARD ( ) Step 8: MOVE_FORWARD ( ) c) Step 1: MOVE_FORWARD ( ) Step 2: MOVE_FORWARD ( ) Step 3: ROTATE_LEFT ( ) Step 4: MOVE_FORWARD ( ) Step 5: MOVE_FORWARD ( ) Step 6: ROTATE_RIGHT ( ) Step 7: ROTATE_RIGHT ( ) Step 8: MOVE_FORWARD ( ) d) Step 1: MOVE_FORWARD ( ) Step 2: MOVE_FORWARD ( ) Step 3: ROTATE_RIGHT ( ) Step 4: MOVE_FORWARD ( ) Step 5: ROTATE_RIGHT ( ) Step 6: ROTATE_RIGHT ( ) Step 7: MOVE_FORWARD ( )

Step 1: MOVE_FORWARD ( ) Step 2: MOVE_FORWARD ( ) Step 3: ROTATE_LEFT ( ) Step 4: ROTATE_LEFT ( ) Step 5: MOVE_FORWARD ( ) Step 6: ROTATE_RIGHT ( ) Step 7: MOVE_FORWARD ( ) Step 8: MOVE_FORWARD ( ) This is correct. If the robot begins at the top-right of the "T"-shape, facing towards the left, then it will trace out the "T"-shape as shown. Initially the robot moves forward twice to draw the horizontal top of the "T", then turns back on itself and moves forward once, taking it to the center of the top. The robot then turns right and moves forward twice to draw the vertical line of the "T"-shape.

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 for any known value of n can always be predicted. b) The algorithm always displays the same answer, regardless of the value of n. c) It is impossible to predict the value of the answer displayed, even if the value of n is known. d) The answer displayed by the algorithm can be predicted for some values of n, but not for others.

The answer displayed by the algorithm for any known value of n can always be predicted. This is correct. The steps are always followed in the same order and give the same results for a given value of n. Therefore, for any known value of n, the number which will be displayed can be calculated by following the steps through.

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) The average can be viewed without knowing the process of how the average was computed. b) There is an equal sign present in the command. c) There are steps that are followed in order to complete the calculations. d) There is math being used in order to calculate the average.

The average can be viewed without knowing the process of how the average was computed. This is correct. Abstraction is the process by which complicated procedures can be replaced by a simplified representation. In this case, excel is summing the values in cells A1 to A20 and dividing this by the number of cells (20). However this process is represented by a simple command, =AVERAGE(A1:A20), which describes what is actually calculated by this process. Therefore this is an example of abstraction.

stage

The background of a project in Scratch which can have scripts, backdrops, sound, etc.

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

The binary instructions from the program are loaded into RAM. The CPU reads and executes instructions, storing and accessing data from RAM as needed. This is correct. This roughly describes how a program is executed. When a program has been compiled, it is converted into machine code (written as binary numbers), understandable by the CPU (Computer Processing Unit) which is the part of a computer which performs operations and calculations. RAM (Random Access Memory) is a short-term memory which is used by a computer to store data such as instructions and variables it needs to complete tasks.

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

The instructions lack descriptive qualifiers This is correct. Descriptive qualifiers are needed to determine for example which ingredients are added first, which ingredients are added later, and how long the tin should be in the oven for.

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

The process is a cycle, with results from one run of the cycle feeding into the next. This is correct. To iterate means to repeat a process, although not necessarily with the same data or results. This describes the development process since results from the evaluation and testing in one cycle are then used to create ideas for improvement and extension and start a new cycle of development.

Which of the following are benefits of well-named variables? Select two answers. a) The program will run faster. b) The program will use less resources. c) The program will be easier for others to debug. d) The program will be easier to read.

The program will be easier for others to debug. The program will be easier to read. This is correct. It is easier for a person to debug the code if well-named and descriptive variables are used, as once they understand what the code should do and what it is actually saying they can find and remove bugs much more easily. This is correct. For a person reading the code, well named variables describe what that variable represents, and hence makes it much easier to read and understand what the program is doing using those variables.

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 meaning of different characters and words in an artificial languages is too complicated c) The syntax of natural languages is easy to translate by computers d) The meaning of different characters and words in an artificial languages is explicit and unambiguous

The syntax of artificial languages is explicit and unambiguous This is correct. An artificial language, such as a programming language, is much easier for computers to understand as the syntax can be made unambiguous: a series of well-defined rules allow each expression to always be interpreted in the same way by the computer.

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

They are not very ambiguous This is correct. Computer programming languages, in contrast to natural languages, are designed to be as unambiguous as possible. This applies to both low-level and high-level languages.

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) Try changing some of the inputs to see under what circumstances the program is not working and what type of error may be occurring. b) Add statements to display the state of the program at various points to try and identify where the error might have occurred. 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) Retype each statement in the program again, being extra careful not to make mistakes this time.

Try changing some of the inputs to see under what circumstances the program is not working and what type of error may be occurring. Add statements to display the state of the program at various points to try and identify where the error might have occurred. This is correct. By identifying when and what type of error is occurring, it will be easier to ascertain what the cause of the error might be, and therefore what fix might need to be applied. This is correct. By looking at the state of the program (e.g. by displaying the values of variables) at various points and comparing this to the expected state at this point, the part of the code in which the error occurs can be identified quickly, meaning it can then be fixed faster.

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

Use names which describe what each variable represents to make code easier to understand Use concise names to avoid typos and keep code tidier This is correct. This is an important idea when naming variables: code is easier for humans to parse and therefore edit when the purpose of each variable is clear. This is correct. A good variable name should be as short as reasonable while still being informative. Using very long variable names can slow down coding and make it harder to see what is going on in the code.

broadcast

When blocks of code are executed at a given time by communicating (or broadcasting) a message.

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) Whether a user got a specific question right or not b) The percent score of the user c) The correct answer choice for a particular question. d) The number of questions in the quiz.

Whether a user got a specific question right or not This is correct. A boolean variable can have two possible values - true or false. This makes ideal for determining if a user got an individual question right (true) or not (false).

reporter blocks

a block in Scratch with round edges that contains a value (numbers, sentences, etc.) and can be used inside other blocks.

imperative statement

a command statement with a verb phrase that indicates an operation to perform (example: move forward)

natural language

a complex, but structured language, both written and spoken, that has evolved naturally in humans through use, repetition, and adaptation.

attributes

a description of what the computer is doing or the values of variables at any given moment.

state

a description of what the computer is doing or the values of variables at any given moment.

algorithm

a finite set of instructions that accomplish a specific task. sequencing: executes statements one at a time - in order, one after another.

artificial language

a limited size language, usually developed by a small group for specific purposes. Usually much simpler and structured.

floating point number

a number that may have digits after the decimal place. Can be a type of variable.

low-level language

a programming language that has little or no abstraction and communicates closely to the hardware using machine language. Less natural for humans.

high-level language

a programming language that is easier for humans to read, write, and parse. Guaranteed to be unambiguous.

visual programming language

a programming language that lets users drag and drop icons into organized blocks of code to create programs rather than typing text.

string

a series of characters at any length. Can be a type of variable.

character

a single letter, digit, or symbol that can be a type of variable.

descriptive qualifier

a specific adverb or adjective that further qualifies or limits the meaning of a word (example: left shoe)

placeholder

a variable for a particular value or attribute.

Boolean values

a variable to represent true or false.

sprite

an object in Scratch that performs functions through scripting.

bit

binary digit - a 0 or 1.

event

blocks of code that trigger corresponding behavior (example: Green Flag - starts program)

declaring variables

creating variables in a programming language

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) bool d) float

float This is correct. The square root of an integer may be another integer or a non-integer number (e.g. the square root of 2 is 1.4142...). Since the floating point number (float) data type stores decimal numbers, this makes it an ideal data-type for this variable.

code statement

is a part of program code that expresses an action to be carried out

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 offtemp - A variable which records the temperature of the room to the nearest whole degree Fahrenheitname - 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 - integer, temp - boolean, name - string b) light - string, temp - integer, name - boolean c) light - boolean, temp - integer, name - string d) light - boolean, temp - string, name - integer

light - boolean, temp - integer, name - string This is correct. A boolean should be used for light as it can only have two possible value (on/off or true/false). An integer should be used for temp, as it can take many different possible values which are whole numbers. A string should be used for name since it can contain a combination of letters (and/or numbers).

sensing blocks

light-blue colored Boolean blocks that are used to detect different factors of a project such as touching.

Sensing Blocks

light-blue colored Boolean blocks that are used to detect different factors or a project such as touching.

operator blocks

light-green colored blocks of code used to handle strings and math equations in Scratch.

array

lists of other variables.

binary

machine code that is a direct, low-level translation from the high-level source code, and is a pattern of 0s and 1s.

machine code

machine-level instructions that are uniquely read by computer processors using patterns of 1s and 0s.

motion blocks

medium-blue colored blocks used to control a sprite's movement in Scratch.

Which of the following blocks should be added to the end so that this code segment causes the sprite to draw a rectangle as desired? (refer to image) a) move myNum - 50 steps b) move myNum + 100 steps c) move myNum steps d) move myNum + 50 steps

move myNum + 50 steps This is correct. The length of the first side is equal to the initial value of myNum. The value of myNum is then increased by 100, meaning the second side is 100 longer than the first. The value of myNum is then decreased by 50, making it 50 greater than its original value, and the side drawn is of length myNum - 50, meaning it is the same length as the first (100 less than the second). As the value of myNum is not changed before the 4th side is drawn, it must be drawn at a length of myNum + 50 to make it the same value as the second side, 100 more than the original value of myNum.

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

num1 = 8 - 3 num2 = 2 * num1 + 1 print(num2) Choice B is correct. This code is written in a high-level programming language: it uses some Instructions in english (e.g. print) and mathematical operators, but uses a formal and logical structure which removes ambiguities present in natural language.

source code

programs written in high-level languages.

looks blocks

purple-colored blocks of code in Scratch that are used to control a sprite's appearance.

iteration

repeatedly applying a process with the goal of coming closer and closer to a solution

iteration

repetition - one complete step of a loop, repeated until a certain condition is met.

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

speed - float, passengers - int, destination - string This is correct. The variable speed takes decimal number values, therefore a float, which represents decimal numbers is the best choice. The variable passengers will always be a whole number (integer), therefore an int is the best choice. The variable destination is a word (or multiple words) formed of letters, therefore a string, which is made up of multiple characters (letters, numbers, symbols) is the best choice.

costume

the appearance of a sprite.

iterative development process

the process by which computer programs are designed, developed and tested in repeated cycles

innovating

the process of imagining something that does not yet exist, but that has potential value, and making it real through the application of design, implementation, and production

abstraction

the process of removing or suppressing details to create a manageable level of complexity. Another way of thinking of abstraction is to think of it as using one word, phrase, or command that encompasses many smaller items, details, or commands.

compilation

the process of source code being translated into machine code.

process

the program code and current activity that is being executed in a computer program.

position

the x and y coordinates on the stage in Scratch.

debug

to identify and remove errors from a computer program

ambiguity

uncertainty or being open to more than one interpretation.

input

user interaction with a program via clicking, mouse movement, or keyboard entry.

selection

uses "if...then" to tell a computer how to select a step or to tell the sequence that it should be executed.

storage

what the computer "stores" or needs to remember to execute a program.


संबंधित स्टडी सेट्स

Sociological Theory and Research

View Set

Chapter 7. Relationship Development

View Set

Programming Logic and Design: Ch 1-5

View Set

Nutrition Concepts and Controversies, Ch. 4

View Set

Hawkes Learning Business Statistics 4.3

View Set

SKILL SET ATI ( MOBILITY, INFECTION, BOWEL ELIMINATION, OSTOMY CARE)

View Set