CS108L Mideterm Exam
CS108L Mideterm Exam
CS108L Mideterm Exam
Teresa Espinoza_______________________________________
SCORE: __________/ 10
A K shape.
A square shape.
A rhombus or diamond shape.
A W shape.
A J shape.
Hint:
Headings are set based on the point of a compass as used in
navigation.
2. Unless you specify the turtle location, where in the NetLogo world does the create-turtle
command of NetLogo create a turtle?
a
330791820
3. After a single turtle has been created, the procedure below is called. What are the
coordinates of the turtle when the procedure ends? Hint: if you do not think any answer is
correct, try working your answer againmake a sketch.
to move-it
setxy 0 0
set heading 0 ;;directly up on the screen
forward 5
left 90
forward 7
forward 3
right 90
forward 10
end
a)
b)
c)
d)
e)
-5,-10
-10,15
5,10
-20, 10
10, -5
4. A student is making a model of traffic patterns in a city. As part of this process, the student
decides to include in model the number of lanes each road has, but does not include the
width of each lane. This decision is part of which of the three As of computional thinking?
a) Abstraction
b) Automation
c) Algorithm
d) Asynchronous
e) Analysis
330791820
8.
A loop
Redundant
Very, very dead
Confused
Inefficient
In the RGB color representation below which of the colors below has the same value for its
R, G and B?
a)
b)
c)
d)
e)
Medium Yellow
Sky Blue
Light Gray
Orange
Light Purple
10. What factors allow an agent-based model to produce different results upon different runs
with the same input parameters?
a) The use of agent based variables.
b) The use of random numbers in the model.
c) The use of global variables.
d) The use of input parameters.
e) The use of patches in the model.
330791820
11. Which NetLogo code segment placed within an ask turtles command block will produce an
example of the wiggle walk?
a)
right random 15
left random 15
forward 1
b)
right 90
left 90
forward 1
c)
d)
e)
12. In NetLogo, what is the range of values reported by: random 100? Hint: random 4 will
never produce a 4.
a)
b)
c)
d)
e)
0 through 99
0.0 through 100.0
0.0 through 99.9999
1 through 100
1.0 through 99.9999
330791820
let b 155
show (r > g) and (r > b)
show (g < b) or (g > r)
show (g < b) and (g > r)
a) false, true, false
b) true, true, false
c) true, false, false
d) true, false, true
e) false, true, true
15. What kind of variable would be best suited for describing a tigers age?
a)
b)
c)
d)
e)
Feline variable
Agent variable
Global variable
Local variable
Predator variable
330791820
STUDENT NAME:_____________________________________________
DATE: ___________________
SCORE: __________/ 10
a) 5
b) 16
c) 25
d) 6
e) 12
17. In the default NetLogo 2D world view, which is the most accurate decription of the
result of the following code? Hint: pycor is the NetLogo way of refering to the y
dimension of an ordinary Cartesian (x-y) coordinate graph. The middle patch has
coordinates pxcor = 0 and pycor = 0, the one below the middle patch has
coordinates pxcor = 0 and pycor = -1.
ask patches
[
ifelse pycor < 0
[ set pcolor blue
]
[ set pcolor red
330791820
]
]
a) The patches on the left half of the world are blue and the patches on the
right half of the world are red.
b) The patches on the bottom half of the world are blue and patches on the
top half of the world are red.
c) The patches on the right half of the world are blue and the patches on the
left half of the world are red.
d) All the patches turn blue. Then all the patches turn red.
e) All the patches turn blue since pycor must always be positive.
18. In a computer program, what is a variable?
a) A variable is part of the program that changes randomly each time the program
is run.
b) A variable is a memory storage location referenced by a name and containing a
value that can be used and changed.
c) A variable is the part of the code that changes itself.
d) A variable is a change in the programming language used when creating a
program.
e) A variable is a memory storage location that changes each time the
programmer accesses it.
19. In a model where fish are born, reproduce and die, you might want to keep track of
the total number of fish that were ever born. This would require use of a global
variable since individuals come and go. How would you define a global variable?
a)
b)
c)
d)
A variable that can hold many different values at the same time.
A variable that can only be accessed from outside the program.
A variable that is shared by and can be accessed by all parts of a program.
A variable used in models that effect the whole world such as climate models,
human population models and models of the ocean currents.
e) A variable that can only be used in the procedure in which it was declared.
20. In a NetLogo program with max-pxcor = 6, max-pycor = 6 and the location of the
origin at the center, how many patches are colored red after the setup procedure
below is called?
to setup
clear-all
let myCount 0
330791820
ask patches
[
set pcolor green
if (myCount < 50)
[
set pcolor red
set myCount (myCount + 1)
]
]
show myCount
end
a)
b)
c)
d)
e)
21. Assume that you have a stochastic model that is a good abstraction of a real-world
situation. Which of the following is the least important (or unimportant) element
when running a stochastic computer model to make generalizations and
conclusions about the models behavior?
a) Sweeping input parameters.
b) Repetitions at each set of input parameters.
c) Recording the output and recording which set in input parameters were used in
the run that generated that output.
d) Randomly selecting input parameters until the required output is obtained.
e) Using some kind of statisical tools to understand, visualize or average results.
22. Which of following facts (all of which are true) acts as negative feedback for a
population of ants?
a) The fact that each ant needs food to live and the supply of food is finite.
b) The fact that almost all species of ants sleep quite frequently.
c) The fact that among the worker ants of a colony, there is a division of labor
into tasks such as colony upkeep, foraging and nest defense.
d) The fact that there is no head of the colony telling the ants what to do. The
subsistence of the colony is instead supported by a self-regulatory
mechanism that provides resilience and robustness, through the local selforganization of the ants.
e) The fact that an ant is one of the worlds strongest creature in relation to its
size.
330791820
23. What is the main difference between a deterministic simulation and a stochastic
simulation?
a) A deterministic simulation is used to determine whether the model is correct by
checking it against a known result. A stochastic simulation is used when the
expected results are not known.
b) A deterministic simulation involves numbers and rigorous mathematics whereas
a stochastic simulation does not.
c) A deterministic simulation does not involve randomness whereas a stochastic
simulation does involve randomness.
d) A deterministic simulation is more accurate whereas a stochastic simulation is
more intuitive.
e) A deterministic simulation is used to simulate real world events and problems
whereas and a stochastic simulation is used in games.
24. Assume that before the Netlogo program below is called, 100 turtles have been
created each with its energy value equal to 10. Then, when the following Netlogo
procedure is called once, will it hatch any turtles?
turtles-own [energy]
to go
ask turtles
[
forward 1
set energy (energy 1)
if (energy < 0) [ die ]
if (pcolor = green) [ set energy (energy + 15) ]
if energy >= 10 [hatch 1]
]
end
a)
b)
c)
d)
330791820
a)
b)
c)
d)
e)
49
50
over 400
it is stochastic
it depends on input
26. The NetLogo procedure below is executed with 2D world settings of max-pxcor = 16,
max-pycor = 16 and the location of the origin at the center. What pattern will be
drawn by the turtle:
330791820
a)
b)
c)
d)
e)
27. When the NetLogo procedure below is called, the lines drawn by the turtle will:
a) Never cross
b) Cross once
330791820
c) Cross twice
d) Cross four times
e) Cross five times
28. Within the field of complex adaptive systems, the structure of termite mounds is a
classic example of _______?
a) Termites and other creatures being much smarter than we usually recognize.
b) How very little we as humans really understand about the natural world
around us.
c) How both deterministic and non-deterministic processes can merge in a
positive feedback loop.
d) Emergent patterns that develop from simple interactions of agents.
e) How both positive and negative feedback loops contribute to structural
solutions in crowd dynamics.
29. Why are exit conditions so important for recursive programs?
a) They allow the recursion to end and not to run indefinitely.
b) Recursion is unstable, and must know how to exit.
c) If no exit case is provided, recursive programs cannot continue beyond one
iteration
d) Exit cases are not vital, recursion works fine without them
30. What kind of variable would be best suited for describing an attribute of the
environment (e.g temperature)?
a)
b)
c)
d)
Agent variable
Environmental variable
Global variable
Local variable
330791820
330791820