Practice Test Questions CHAP 2-3: 1. In Alice, information about a

advertisement
Practice Test Questions CHAP 2-3:
1.
In Alice, information about a world and its objects are stored in properties. What programming "piece" (statements
and phrases) allows the user to ask questions about these properties?
a. functions
b. instructions
c. control structures
d. expressions
2.
Program code involves various "pieces" (statements and phrases). For each piece, numbered 1 through 4, match the
piece with its associated definition, labeled a through d.
___ 1. instruction
___ 2. control structure
___ 3. function
___ 4. expression
a. asks a question about a condition or computes a value
b. a math operation on numbers or other kinds of values
c. a statement that controls the execution of a block of instructions
d. a statement that executes to make objects perform a certain action
3.
An If/Else statement involves making a decision based on a current condition in the world.
a. True
b. False
4.
Arithmetic operations, such as additional, subtraction, multiplication, and division and not possible in Alice.
a. True
b. False
5.
In the firstEncounter example described in the textbook, the task is to move a “Robot" near a rock. Which solution
below is the most effective?
a. experiment with moving the "spiderRobot" various distances while moving its legs, until a good distance is found
b. move the "spiderRobot" the value of the distance returned by the "spiderRobot distance to rock" built-in function,
while the "spiderRobot" moves its legs
c. move the "spiderRobot" the value of the distance returned by the "spiderRobot distance to rock - the width of the
rock" built-in function, to avoid collision, while the "spiderRobot" moves its legs
d. none of the above
6.
The distance to function in Alice returns the value of the distance from the center of one object to the center of
another object. Since this returned value is precise, objects in Alice will never collide.
a. True
b. False
Page 1 of 8
7.
Repetition is where a section of the code is run a number of times.
a. True
b. False
8.
Suppose one object is moved toward another object, based on the value returned by the built-in distance to function
between the two objects. Further, these objects collide when the world is run. How can this collision possibly be avoided, most
effectively?
a. move the position of one object before starting the world
b. use an arithmetic expression to subtract a small value from the distance, as returned by the distance to function
c. move the position of both objects before starting the world
d. use a "do together" block, coupling the above statement with another statement to move the colliding object a
small distance, so that the net value of both moves results in the objects not colliding
9.
What is a control structure?
a. a programming statement that allows the programmer to control the order in which instructions are executed
b. a slide which allows the programmer to control how fast the world is played
c. the use of built-in functions specifically written such that collisions can be avoided
d. the ability to resize and reposition an object once it is dragged into the world
10.
The only control structures defined in Alice are the "do together" and "do in order" statements.
a. True
b. False
11.
The answer to the question, "Is the tree taller than the polar bear?" would be either true or false.
a. True
b. False
12.
A boolean value is ____________.
a. an integer
b. a string
c. either true or false
d. the value 0, 1, or -1
Page 2 of 8
13.
Which of the following control structures implements conditional execution?
a. If/Else statement
b. Loop statement
c. Do together statement
d. Do in order statement
14.
An If/Else statement controls program flow. This flow normally depends on asking a question, where the answer is
always __________.
a. a number value
b. a boolean value
c. a string value
d. an object
15.
Which of the following built-in function calls and expressions are acceptable for use in an If/Else control structure.
a. Is the spiderRobot shorter than the rock?
b. How far is the spiderRobot from the rock?
c. Move the spiderRobot towards the rock.
d. Is the head of the spiderRobot red?
16.
It is never acceptable to have the "else" section of an If/Else control structure in Alice, "do nothing".
a. True
b. False
17.
Six relational operators exist in Alice, grouped together in the math sub-category of a World's built-in
functions. Match each description, labeled 1 through 6, with its appropriate relational operator symbol, labeled a
through j.
___ 1. is equal to
___ 2. is not equal to
___ 3. is greater than
___ 4. is greater than or equal to
___ 5. is less than
___ 6. is less than or equal to
a. <=
b. <
c. >>
d. =!
e. =
f. >=
g. !=
h. <<
i. ==
j. >
Page 3 of 8
18.
A property of an object is
a. the default method that is executed in an ALICE program
b. a single “thing” in a virtual world.
c. a question involving the state of the object e.g. the snowman is taller than the snowwomman
d. features or characteristics of an object e.g. the snowman’s head is pink
19.
Nesting occurs when
a. when one block of code is completely inside another
b. when a sequence of statements are executed conditionally
c. when a sequence of statements are executed simultaneously
d. when a sequence of statements are executed sequentially
20.
a “do together” block occurs when
a. when one block of code is completely inside another
b. when a sequence of statements are executed conditionally
c. when a sequence of statements are executed simultaneously
d. when a sequence of statements are executed sequentially
21.
a “do in order” control statement is used when
a. when one block of code is completely inside another
b. when a sequence of statements are executed conditionally
c. when a sequence of statements are executed simultaneously
d. when a sequence of statements are executed sequentially
22.
Which of the following ALICE statements best represent the following flowchart?
IS
mummy’s
height <=2
Resize
mummy
toto
Resize
mummy
twice
itsits
original
size
twice
original
size
Is Is
mummy’s
pharoah’s
height <2
height
<=2?
Resize pharaoh to
twice its original size
Page 4 of 8
Do nothing
a)
If mummy’s height <=2 then
resize mummy 2
else
resize pharoah 2
b)
If mummy’s height <=2 then
resize mummy 2
else
If pharoah’s height <=2 then
resize pharoah 2
else
do nothing
23.
What are the programming steps in order after an initial programming problem is given to you?
a)
b)
c)
write the code / write a storyboard / test the code
write a storyboard / write the code / test the code
write the code / test the code/ write a storyboard
24.
The first editing pane in ALICE is always given what default name?
a)
b)
c)
d)
move
say
walk
run
25.
In Alice, the following is a control structure
a)
b)
c)
d)
say
do in order
function
parameter
Page 5 of 8
26.
Consider the following:
True or false:
it is false.
If the condition is true, then only the first part of the statement is executed. Nothing happens if
a)
b)
True
False
27.
In the real world, how many lines of code would a program typically have?
a)
b)
c)
d)
100
200
300
Many thousands
28.
What built-in method is used to display a comic-book style text bubble on the screen?
a)
b)
c)
d)
say
speak
talk
words
29.
In ALICE, what does it mean to say that the “cat's vehicle is the horse”?
a)
b)
c)
d)
If the cat moves, so does the horse
Clicking on the cat makes the horse move
If the horse moves, so does the cat.
none of the above
Page 6 of 8
30.
run?
Consider the code shown below. How many meters does the snowman move forward when this code is
a)
b)
c)
d)
2
5
7
10
31.
In ALICE, to make the ToySoldier go around the Chicken, which of the following can do the job?
a)
b)
c)
d)
ToySoldier go around the Chicken
ToySolider turn left 1 revolution around Chicken
ToySolider turn right 1 revolution as seen by Chicken
both a and b
32.
A comment in an Alice program can be:
a)
b)
c)
d)
an instruction that causes an action to take place
an explanation of what the program does
an expression that holds a value when the program runs
A special property intrinsic to all objects
Page 7 of 8
Corrected answers which have been corrected again!
1a
2 dcab 3a
4b
7a
8b
omit questions 10 and 11
9a
5c
6b
12c
13a
14b
15a (also d could be correct as well)
16 b 17 igjfba
18d
19a
20c
21d
22b
23b
24d
25b
26a
27d
28a
29a
30d
31c
32b
Page 8 of 8
Download