Chapter 17 -- Part 2: Practicing Programming Languages
The table shows short-circuiting.
Short-circuiting is caused by the fact that the circuit only depends on the first input.
The circuit shown in the figure is composed of two logic gates.
The output is true.
One of the inputs is true if the result of an OR gate is true.
The input is false.
The AND gate's result must be true.
If both inputs are true, an AND gate returns true.
The input must be true.
The Logic Table can be used to determine the options for the input.
One of the major components of computer science is selection.
Sequence and iteration are moving through a collection.
When a condition is true, you know what you want to do.
This is often referred to as an I-statement.
When a condition is false, you know what you want to do.
This is usually the ELSE in a statement.
The code segment should be considered.
Information about whether the variable senior is true or not is not included.
Iteration is one of the most important components of a computer science program.
Sequence and selection are used to choose which block of statements will execute.
When you want to repeat a behavior, iteration is used.
You want to do it a lot.
You want to do something until the situation is right.
You need to see the elements of the collection.
Consider the code segment.
Tables can be used to trace loops.
Mystery is 0 and c is 1.
The loop condition is not evaluated until the last block is processed.
The mystery would be displayed in this block.
The other blocks of code can be traced using a table to confirm that their output is the same as Example 1.
A list is a collection of items.
Each language has its own way of handling lists.
The way lists are created, modified, and accessed on the exam reference sheet may be different from what you practiced.
The smallest index is 1.
The length of the list is the largest list index.
You can assign a variable to a list of values.
At the end of the list, you can add one element at a time.
At a specific location in the list, you can add one element at a time.
The elements can be removed by their location.
The length of the list is adjusted when elements are added or removed.
Key statistics are stored in a database by a retail company.
The prices of all items in the store are stored in a list.
The question wants you to assign the index to the max.
The element is assigned to max by choice.
The value stored at i to max is not in the list.
A track coach is writing code to record the mile times of runners on her team.
She has a list of each team member's name.
When a new team member is added to her team, she wants to put them in the correct spot.
The name would not be placed at the end of the list.
Since INSERT works for all situations, it makes sense to use it instead of APPEND.
You will need a loop to find where you need to insert the new name.
Length is important to make sure your loop doesn't go outside the list.
The removal of elements of the list is unrelated to the problem.
There are two types of multiple-choice questions on the End-of-Course exam.
The two answers that are correct are listed in the exam as separate from the other types of multiple-choice questions.
You have to choose the correct answers in order to get credit for the question.
No credit is given.
The names list has at least five names.
The track coach wants to show all of the elements.
The other blocks show the elements of the list.
Choices A and B do the same thing, but they use different loops.
It is easier to read choice A than choice B.
An extra variable isn't needed in choice A.
Since the list is empty at the end of the loop, choice would be a strange approach.
Choice C doesn't work correctly.
Since name is the name itself, it would return an error.
A procedure is a way to manage instructions in a program.
Each language has a different way to use a procedure.
You can have a lot of parameters.
The correct number of parameters and the name of the procedure are required to call the procedure.
Do not worry about the data type.
The question will specify whether they are numbers or strings.
The name of the parameter will be used to explain their type.
A person uses a list to track the number of minutes they walk.
The list is called minuteslist.
The minutes for each day are represented by elements.
The minutes the person walked on day 1 would be returned.
A person wants to write a procedure that calculates the average number of minutes walked per day.
The average will be returned as an input and an output.
There is an error in the code below.
Since no elements were added or lost, choice is incorrect.
The choice is incorrect since the PROCEDURE would work with any list you use to call it.
The call to the PROCEDURE would include minuteslist.
The minutes list is assigned inside the procedure.
This would be a mistake.
You can assume that there is at least one element since the question said that the list is 1 to n. The procedure was described as having a return.
Choice is correct.
You are trying to use the findAverage procedure to display the average if minuteslist exists.
Since the average would be returned but not displayed, choice is not appropriate.
It is not appropriate to choose since thelist is the one that matters.
Choices (B) and (C) both show the output.
It would be a matter of coding style, since both are clear.
The purpose of this question is to see if you understood how to call a procedure and if you noticed that you needed to display the result.
The question is more difficult because you need to read carefully about what you are required to do and go against some of what you practiced while coding to find the correct answer.
A person is making a program.
She has created a list of countries.
She would like to check for repeat countries and remove them.
The isFound(list, name) procedure is used to do this.
She wants to count how many times a country occurs.
The procedure is called how many times.
The number of times the name appears in the list will be returned.
Count is never given a value.
If the name is in the list, count will be incremented each time the loop occurs.
There are two different solutions in choices C and D. Choice uses isFound and the REMOVE method to prevent count in each loop.
Choice does not use isFound.
You could describe choice (D) as a more elegant solution since it has less detail and is more clear.
The choice removes elements in the list that were not part of the algorithm described and may lead to issues elsewhere in the code.
Both choices would have to be used for full credit on the question.
You can move around a two-dimensional grid with this category.
The robot is in the triangle.
The robot is facing in a certain direction.
There is a robot in the top left corner.
The robot can't make an illegal move.
It can't leave the grid or go into the black squares.
The robot may be moving in a different direction.
The robot moving toward a goal would be explained in the question.
You can see where the goal is located in the grid by using a symbol other than the triangle.
As shown here, it is often a gray square.
Some sections may be filled in.
The robot can't go to the parts of the grid that are filled with black.
The robot is trying to get to that part of the grid.
The question explains what each color is.
Write code that creates movement.
If you don't use a computer, plan out what motion looks like.
If you want to try out the directions, write them down and ask someone else to do it.
The robot operations can be used from the chart.
There are more details about robot operations here.
The robot is in a grid of squares.
The robot is in a triangle and facing up.
If you want the robot to end up in the bottom right square facing up, you have to write steps.
ROBOT procedures should be used as much as possible.
Some may be more complicated than others.
There is a bridge between requirements and actual code.
It follows the logical order of code, but the language is easier to understand.
Pseudocode can be used to plan solutions for robot questions.
The grids below show the different starting positions of a robot.
The robots are facing up.
The robot can move into a white or gray square, but can't move into a black region.
The program was written to move the robot.
If the robot is in the gray square, the program uses the procedure GOAL_REACHED to determine if it is true or false.
Either position would work.
The best way to see each of them is to place your pencil on the grid and move it according to the code.
The loop would need to run many more times than in position I.
There is a reference sheet for the End-of-Course Exam.
The instructions are going to be block or text.
There are eight categories for the instructions.
Practice programming to solve problems on a computer is the best way to learn programming.
Review flashcards and saved quizzes
Getting your flashcards
You're all caught up!
Looks like there aren't any notifications for you to check up on. Come back when you see a red dot on the bell!