AP COMP 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan 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)

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

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?

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?

3, 2, 4, 1

he code segments for making a Scratch program which simulates a conversation between the user and a sprite on-screen are given below. 12345 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

Which of the following best describe examples of abstraction

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.

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 statements comparing low-level programming languages (such as assembly language) and high-level programming languages (such as python or java) are correct?

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.

Which of the following is a valid reason for giving variables meaningful names in a program?

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

Which of the following best represent examples of abstraction?

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.

Consider the following statement which refers to the block 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?

Abstraction

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?

Abstraction

Which of the following best describes how abstraction makes code written in higher-level programming languages easier for humans to parse?

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.

Tamara is writing code as part of a large project. She has just compiled her code and run it, but the result is not exactly as expected. Which of the following strategies would be efficient ways to "debug" her code so that it works as intended? Select two answers.

Add statements to display the state of the program at various points to try and identify where the error might have occurred. Try changing some of the inputs to see under what circumstances the program is not working and what type of error may be occurring.

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 is a reason for the importance of variables in programming?

All of these

Identify the variable type- (List- 1,2, 3, 4, 5)

Array

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.

Which of the following variable types is characterized by allowing only two possible values to be stored?

Boolean

Which of the below options would be the best set of instructions to give for a program designed in Scratch?

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.

Which of the following best describes "compilation" in reference to computer science?

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

Which of the following statements are NOT true about high level programming languages? Select two answers:

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

helps to identify and remove errors from a computer program.

Debugging

A computer cannot run several processes at a time.

False

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?

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

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?

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.

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?

Float

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)

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

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

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 determinedII. Following the instructions in the algorithm will always result in the same outputs, regardless of any inputsIII. The instructions in the algorithm contain all necessary information to be implemented

I and III only

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.

I and III only

Which of the following describe advantages of Chelsea's suggestion over Greg's original script? 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

I, II and III

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

I, II and III

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

II. The instructions lack the required imperative statements

Understanding of the life cycle of a program is an essential component to becoming an effective programmer. Which of the following is the best example of how the life cycle of a program should work?

Idea→algorithm→write code→execute code→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:

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

Which of the following is NOT an advantage of giving variables meaningful names in a program?

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

What is the function of the Central Processing Unit?

It is the processor or brains of the computer where calculations take place and instructions from programs are carried out

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?

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

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?

Naming conventions Adequate and appropriate comments

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

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?

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?

RAM

A statistics teacher wishes to create a program on her calculator that generates a random even integer. The command built in the calculator to generate a random positive integer is RANDOM(a,b). This command generates a random integer between integers a and b (and including a and b). Which of the following lines of code will ensure that the random integer generated will be even?

RANDOM(a,b) * 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?

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 facingROTATE_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?

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

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?

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

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

Which of the following measures can a programmer take to help ensure that a program produces correct output?

Test multiple inputs on the program Develop the program in smaller steps, ensuring each step is correct Find the efficiency of the code

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?

Testing

Consider the following algorithm which uses an integer variable n. Double the value of n Add 34 to the answer Round the answer to the nearest ten Sum the digits of the answer Display the final answer Which of the following statements best describes the predictability of the results when this algorithm is run on a computer?

The answer displayed by the algorithm for any known value of n can always be predicted.

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?

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

Which of the following best describes how a compiled program is run by a computer?

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

The 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?

The color of the fish

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?

The instructions lack descriptive qualifiers

Which of the following best describes why the development process by which computer programs are created is described as "iterative"?

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

Which of the following are benefits of well-named variables? Select two answers.

The program will be easier for others to debug. The program will be easier to read.

Which of the following best describes what a user would hear when the following code is run?

The sound file "Adele - Hello.mp3" played three times consecutively

Which of the following is the MOST important reason computers use artificial languages over natural language?

The syntax of artificial languages is explicit and unambiguous

Which of the following statements about low-level languages are true?

They are generally less readable by humans than other languages They are very rarely ambiguous

Which of the following best describes high-level computing languages?

They are not very ambiguous

Which of the following describes good practice when naming variables in code?

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

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 could NOT be represented by a boolean variable?

Whether a traffic light is green, yellow or red

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?

Whether a user got a specific question right or not

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

The code does not currently work as intended as only 2 of the four scripts run after the green flag. Which of the following changes would fix the problem in the code so that the four scripts run one after another?

change the when i receive sound1 blcok to when i receive mrs smith 2

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?

debugging

A series of characters of any length is an array.

false

Identify the common variable types. (Multiple Answers)

integers characters booleans array float string

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?

light - boolean, temp - integer, name - string

What is Binary?

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

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?

move myNum + 50 steps

Which of the following is an example of code written in a high-level programming language?

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

Compilation is the

process of source code being translated into machine code.

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

What is the correct definition of iteration?

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

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 blcok broadcast sound3 with the block broadcast sound2

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?

speed - float, passengers - int, destination - string

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?

string character

Abstraction in computer science is the

the process of removing or suppressing details to create a manageable level of complexity

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

A _________________________ is an abstraction inside a program that can hold a value.

variable


Set pelajaran terkait

Equations with One Variable Test

View Set

IST 610 - Chapter 3 Security Management

View Set

Foundations Chapter 26 Documentation and Informatics

View Set

Microbiology Learning catalytics lecture 12-26

View Set

Social Psychology- Chapter 5 & 6

View Set

AP European History Unit 5 Exam FINAL Review

View Set