You are on page 1of 13

STUDENT NAME:______

Teresa Espinoza_______________________________________

DATE: ____________Oct 30,2015_______

SCORE: __________/ 10

CS108L Computer Science for All


Week 8: Midterm Exam Part 1
Note: Graph paper has been provided at the end of the test for you to use. It is not used in the
grading process
1. In a NetLogo program, the procedure below is called after one turtle has been created with
its pen down. What shape does the turtle draw?
to go
ask turtles
[
set heading 135
forward 6
left 90
forward 4
right 90
forward 4
left 90
forward 6
]
end
a.
b.
c.
d.
e.

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

The turtle doesnt appear unless it is given a location

The turtle appears at (0,0), also called the origin

The turtle appears at the bottom left corner.

The turtle appears at the top right corner.

The turtle appears at the top left corner.

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

5. In computer science, the three steps of decomposition are:


a) First, the program crashes. Second, computer bugs lay eggs. Third, computer worms
corrupt the files.
b) First, Identify parts of a problem. Second, write the steps for each part. Third,
combine the parts.
c) First, decompile the machine code. Second decuple the procedures. Third,
deactivate the commands.
d) First, write the computer code. Second, run the code in behavior space. Third, verify
the results.
e) First, take apart the solution, Second, take apart the algorithm, Third, take apart the
assumptions.

330791820

6. Which best describes the process of abstraction in computer modeling?


a) Identifying and fixing all the places in the model that can cause the model to either
crash or give incorrect results.
b) Developing algorithms that are robust enough to handle the many special cases that
arise in the model.
c) Developing data structures that can efficiently manipulate the data in the model.
d) Deciding which aspects of the real world are most important to the models current
purpose.
e) Describing, in a human readable form, how the model works so that people other
than the models author can use and extend the model.
7. In a computer program, when a sequence of instructions is executed over and over again
the sequence is called _________.
a)
b)
c)
d)
e)

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

9. What is a local variable?


a) A variable that can only be used by one agent.
b) A variable that can only be used in the procedure or command block where it is
declared.
c) A variable that contain information about agents in the local environment.
d) A variable that is of interest to locals.
e) A variable that can only be used by local agents.

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)

right random 360


forward 1

d)

right random 180


forward 1

e)

right random 360


forward 1

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

13. What is a uniform probability distribution?


a) Only numbers that are regularly used are used when a random number is called for.
b) Most numbers in the distribution are used at some point if a random number is called
for.
c) Every number in the distribution has an equal probability of being used when a random
number is called for.
d) The probability that any number is used when a random number is called for increases
uniformly as the numbers increases.
e) The probability of using a number can only be determined by the user one at a time.
14. The NetLogo code segment below will display which three values in the command center?
Hint: It is easier to make a compound OR statement true than a compound AND statement.
let r 200
let g 10

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

CS108L Computer Science for All


Week 8: Midterm Exam Part 2
16. How may patches does this NetLogo 2D world have?

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)

All of the patches.


None of the patches.
50 patches.
49 patches.
119 patches.

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)

Yes all the turtles will give birth to turtles.


Yes, on average, a bit more than half of the turtles will give birth.
Yes, on average, a bit less than half of the turtles will give birth.
Maybe yes, maybe no. It depends on whether any turtles are on green
patches.
e) No, the turtles will all die.

330791820

25. You decide to


world that has
use the code
of the local
procedure is
command)?

a)
b)
c)
d)
e)

create a fifty turtles in a


over 400 patches. You
below. What is the value
variable i when the
done (in the show

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)

A square spiral that never crosses itself.


A square.
A square spiral where the larger squares cross over the smaller squares.
A sequence of horizontal lines.
A sequence of the same size squares, each rotated at a different angle.

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

You might also like