17 questions
A robot starts in a grid facing north (B3). What is the robot's location and direction after the following program is executed?
data = ["F", "F", "R", "F", "L", "F", "R", "R", "F"]
FOR EACH move IN data
{
IF ( move = "F" AND CAN_MOVE(forward) )
{
MOVE_FORWARD()
}
ELSE IF (move = "R"){
rotate_right()
}
ELSE IF ( move = "L") {
rotate_left()
}
}
A spinner is divided into three sections. The sector labeled Red is four times as large as each of the sectors labeled Blue and Yellow, which are of equal size. Which of the following correctly simulates the spinner?
Which of the following code options can be used to move the robot (the black triangle) to the gray square?
REPEAT 2 TIMES:
{
MOVE_FORWARD ()
ROTATE_LEFT ()
MOVE_FORWARD ()
MOVE_FORWARD ()
ROTATE_LEFT ()
}
REPEAT 4 TIMES:
{
ROTATE_LEFT ()
MOVE_FORWARD ()
ROTATE_RIGHT ()
MOVE_FORWARD ()
ROTATE_RIGHT ()
MOVE_FORWARD ()
ROTATE_LEFT ()
}
REPEAT 3 TIMES:
{
MOVE_FORWARD ()
MOVE_FORWARD ()
ROTATE_RIGHT ()
MOVE_FORWARD ()
}
REPEAT 3 TIMES:
{
MOVE_FORWARD ()
MOVE_FORWARD ()
ROTATE_LEFT ()
MOVE_FORWARD ()
}
Starting in the bottom left corner facing right, where will the robot end up after the following code is called with: controlRobot([2, 1, 3, 6])?
The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially facing right. Which of the following code segments will move the robot to the gray square?
Which of the following images shows the path and ending location of the robot that will result from executing the code above. The starting location of the robot is shown as dotted triangle for cases where the robot does not start and end at the same location.
REPEAT 4 TIMES {
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_FORWARD()
ROTATE_RIGHT(90)
MOVE_FORWARD()
ROTATE_RIGHT(90)
MOVE_FORWARD()
ROTATE_RIGHT(90)
}
Consider the following incorrect program, which is intended to move the robot around the perimeter of a grid, as indicated by the drawing below. The starting position and direction of the robot is indicated in the diagram.
Line 1: 4 TIMES
Line 2: {
Line 3: MOVE_FORWARD()
Line 4: ROTATE_RIGHT()
Line 5: MOVE_FORWARD()
Line 6: MOVE_FORWARD()
Line 7: MOVE_FORWARD()
Line 8: MOVE_FORWARD()
Line 9: ROTATE_RIGHT()
Line 10: }
Given the options below, which lines should be removed so the program will work as intended?
Line 3 and Line 4
Lines 5, 6, 7, 8 and 9
Line 8 and Line 9
Line 9
Which of the following images represents the most likely output produced by the code segment given below?
Why are these icons a good use of abstraction?
They tell us what they mean without needing to use the name
They are difficult to understand
They don't explain what they are
When programmers work together, what is an example of how abstraction in programming can promote collaboration?
Team members can rely on one another to explain their code.
Programmers can write functions without needing to know what they do or how they should work.
Programmers can use functions created by their partners, relying on the functionality without needing to know the specific details of how the function is implemented.
In order for programmers to work together, they must work in the same room.
Abstraction allows programmers to brainstorm more creative solutions to problems.
What is the most likely outcome of running the code shown at right?
It will draw a star with each side 150 pixels long.
The program will stop with an error at line 3 because parameters may not be used in for loops.
The program will stop with an error at line 5 because it is dividing by 0.
The program will run without error, but will not draw anything.
A problem solving approach (also known as stepwise design) in which you break down a system to gain insight into the sub-systems that make it up.
Top Down Design
Function
Variable
Programming languages have some similarities and differences to the "natural" language you use in everyday speech. Select the two true statements about programming languages:
Ambiguities in natural language necessitate the creation of programming languages for controlling a computer
Compared to the number of words in a natural language, the number of defined words in a programming language is very small.
The number of defined words in a programming language is about the same as the number of words in a natural language.
There are typically many possible ways to interpret an instruction written in a programming language.
14. The figure shows a robot in a grid of squares. The robot is represented as a triangle, which is initially facing upward. The robot can move into a white or gray square but cannot move into a black region.
Consider the procedure MoveAndTurn shown. Which of the following code segments will move the robot to the gray square?