CS 108 Final Exam Question Practice

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Within a NetLogo procedure, the code below will fail unless A. An agentset is called first. B. The programmer has defined "turtles" as a breed. C. "Energy" is defined as a turtles-own variable. D. 10 is not larger than the maximum value defined for energy. E. The programmer does not call please before the ask command.

"Energy" is defined as a turtles-own variable.

How many times is the variable "tmp" shown? A. never B. 100 C. 99 D. 101

100

Some agentset commands return an agentset, some modify an agentset and some return Booleans. (Remember, a Boolean only has two possible "values" like yes/no or true/false). In the code below (which is the same as question 5) which agentset command returns a Boolean? A. Other is a Boolean and turtles-here is an agentset B. Turtles-here is true if there are any turtles on that patch C. All the commands above are Booleans D. "If any?" is called with "other turtles-here" as an argument

"If any?" is called with "other turtles-here" as an argument

One way to make using a model easier is to create sliders so that the variables you are studying can be easily changed at the code interface instead inside the code itself. Consider the code below, if the modeler wanted to study how the amount of energy lost to a parent each time they give birth effects fish population WHICH NUMBER should be changed to a variable by creating a slider for it on the interface? A. 10 B. 15 C. 3 D. Change the word "energy" to a slider E. It is not possible

3

What is the final value of n in the NetLogo code below? A. -2 B. 8 C. 10 D. 5 E. 2

8

What is the value of n after the following procedure is executed? A. 2 B. 4 C. 6 D. 8

8

An agentset can be turtles, patches or links. If you ask an agentset to do something, each member of the set does what you ask. If you had a 100 turtles, only ten of them are red, how many numbers will get printed in the command center by the following code? Remember != means NOT EQUAL TO. A. 90 numbers in no particular order. B. 10 numbers, no order C. 10 numbers, 0 through 9, no order D. 100 numbers

90 numbers in no particular order.

When you use a search algorithm you are looking for something in a group of items. There are different algorithms that you can use to do this. What is a Linear Search algorithm? A. A Linear Search algorithm draws a line and checks every item above that line. B. A Linear Search algorithm checks some of the items in the group, the items C. A Linear Search algorithm checks only the items in that line and ignores the rest of the items in the group, that's why it is linear! D. A Linear Search algorithm checks every element one at a time in sequence, until the item you are looking for is found.

A Linear Search algorithm checks every element one at a time in sequence, until the item you are looking for is found.

. What is an agentset in NetLogo? A. A collection of values of agent variables. B. A collection of agents in which order does matter. C. A collection of numbers that are not related to agents and in which order does NOT matter. D. A collection of agents in which order does NOT matter. E. A list of numbers that must be in a certain order.

A collection of agents in which order does NOT matter.

1. Which of the following is NOT an example of an algorithm? A. A recipe for making a cake. B. A large collection of population data. C. The steps that you take when doing long division by hand. D. A set of rules that allow you to sort objects by color. E. A procedure for diagnosing a malfunction in a car engine.

A large collection of population data.

What is a COUNTED LOOP? A. A set of commands that can be used only 5 times. B. A set of commands that can only be used to count off the number of agents in your program. C. A set of commands that is repeated while a certain conditional statement is true. D. A set of commands that is repeated a fixed number of times. E. A set of commands that only counts the number of patches in the NetLogo world.

A set of commands that is repeated a fixed number of times.

What is a CONDITIONAL LOOP? A. A set of commands that only work when certain atmospheric conditions are present. B. A set of commands that is only used when you are feeling like it. C. The condition in the programmer's environment that allows the program to work. D. A set of commands that is repeated a fixed number of times. E. A set of commands that is repeated while a certain conditional statement is true.

A set of commands that is repeated while a certain conditional statement is true.

What is an algorithm in computer science? A. A magical set of words used by a programmer when programming. B. A rhythm that the program works to. C. A problem that needs to be solved one time. D. A set of instructions that can be used repeatedly to solve a problem or complete a task. E. A list of things that needs to be done.

A set of instructions that can be used repeatedly to solve a problem or complete a task.

After creating one turtle with its pen down, which best describes the pattern that will be drawn: A. A spiral where the lines get progressively thinner. B. A figure 8 where the lines all have the same thickness. C. A figure 8 where the lines get progressively thinner. D. A square where the lines get progressively thinner.

A spiral where the lines get progressively thinner.

What is a characteristic of an algorithm? A. Algorithms are colorful. B. Algorithms have clearly defined, doable steps. C. Algorithms are messy and take too long, they should never be used in programming. D. Algorithms NEVER produce an output. E. Algorithms can only be used one time.

Algorithms have clearly defined, doable steps.

Which of the following statements are true of the command "tick". A. Requires that reset-ticks is called before you can use it. B. Is a built-in counter that you read with the command ticks C. Automatically initiates a plotting of all of the plot pens in a plot. D. It is usually found in a go procedure E. All of the above

All of the above

Which of the following statements are true about models. A. All of the are true B. With computer models, programmers can sometimes capture the behavior of the parts of a real world system. C. Building a good model requires identifying objects and behaviors in real world that contribute to larger behavior of the system. D. They capture some features of the "real world". E. Abstraction is the process of picking out features of interest from a real world situation.

All of the are true

If there are two different algorithms that produce the same results on the same data, which might be a good reason for choosing one over the other? A. All of the other answers are good reasons. B. One of the algorithms is easier to understand. C. One is faster. D. One is more effective as the size of the problem (the amount of data) grows. E. One requires less computer memory.

All of the other answers are good reasons.

What is a list in NetLogo? A. A group of items or tasks that need to must be accomplished during the day that are stored on a piece of paper. B. An ordered collection of zero or more elements stored in a variable name. C. A piece of paper used when going to the grocery store to keep track of the items needed to be purchased D. A group of names stored in your address book. E. A procedure that sorts items in order

An ordered collection of zero or more elements stored in a variable name.

By default NetLogo creates all new turtles at the origin. When you make a model and you want to have your 100 agents spread out over the whole world, you need to write code to make sure that they are dispersed. Which setup code snippet below ensures that all agents are on their own patch? A. Create-turtles 100 [ setxy random-xcor random-ycor] B. Create-turtles 100 turtles [ move randomly until no turtles-here] C. Ask n-of 100 patches [ sprout 1] D. Ask 100 turtles [ setxy random 12 random 12] E. Create-turtles 100 [move fd random-float 15]

Ask n-of 100 patches [ sprout 1]

The code below will fail UNLESS: A. An agentset is called first . B. "Fishy" is defined as a breed or agentset. C. Energy is defined as a turtles-own, fishies-own. D. You use reset-ticks in the setup procedure. E. B and C

B and C

Why use algorithms? A. Another programmer can follow the algorithm to solve the same problem. B. All of the other options. C. All the information is in the algorithm - you just have to follow it. D. The same algorithm can be used on problems of different sizes. E. Don't have to think about the details of the problem every time you encounter it - you already know how to solve it.

B. All of the other options.

Why does the following code fail? A. Because "Growing" has not been defined. B. Because "Repeat" is not a command. C. Because "set color" cannot be outside of an "ask turtles" block. D. Because "Repeat" cannot be inside an "ask turtles" block. E. Because "Count" can only be used with an agentset.

Because "set color" cannot be outside of an "ask turtles" block.

Assume that the NetLogo world is originally the default color, black, and has a max-pxcor and the max-pycor of 16 with the origin at the center. What does the following code do? A. Create a white box in the center of the NetLogo world B. Make the right side of the NetLogo world white C. Nothing, the NetLogo world remains black. D. Create a white box in the upper right hand corner of the world.

Create a white box in the upper right hand corner of the world.

Suppose we build a model of fish eating plankton. The fish gain energy by eating plankton and lose energy by moving or giving birth. When the model is run, at first the fish population greatly increases and the plankton population drops to near zero. Then, the fish population falls to zero because all the fish die of starvation and their energy drops to zero. Which change is most likely to make the fish and plankton populations more stable? A. Make the newly born fish stay near their parents. B. Decrease the growth rate of plankton. C. Decrease the birth rate of fish. D. Increase the movement speed of fish. E. Increase the energy fish use when they move.

Decrease the birth rate of fish.

What is algorithm analysis? A. Asking the algorithm lots of questions to understand what it is doing. B. Looking at the algorithm closely to understand what it is doing. C. Looking at the input values that the algorithm needs. D. Developing an understanding of the characteristics of an algorithm for different input parameters

Developing an understanding of the characteristics of an algorithm for different input parameters

Assume you created a program that contains 5 turtles on a green NetLogo world. What is the result of running the above go procedure with the forever option turned on? A. Five straight lines B. Nothing happens C. 25 lines D. One dashed line with twenty fine dashes in it. E. Five squiggly lines

Five straight lines

What two factors are most important when analyzing an algorithm? A. How difficult it is to use and the cost of the software. B. How much input data is needed and the computer it can run on. C. How long the algorithm takes to run and the amount of memory it uses. D. How much money it cost to write the software and where we can find it.

How long the algorithm takes to run and the amount of memory it uses.

In NetLogo, the code below can only be used in which of the following circumstances? A. Inside any "ask turtle" or "ask" breed code block, inside the square brackets. B. After "reset-ticks" in the "go" procedure. C. Inside a certain procedure, the "go" procedure. D. After you define the breeds used at the beginning of the program using the "breed" keyword. E. Inside an "ask-patches" block.

Inside any "ask turtle" or "ask" breed code block, inside the square brackets.

What is the result of the following code? A. it prints "abc" B. It adds three numbers C. It will result in an error message D. It plots three values

It adds three numbers

What NetLogo command is used to create a COUNTED LOOP? A. While B. Rerun C. Again D. Repeat

Repeat

What does the following code do? A. Counts the number of turtles that are healthy that are on the patch. B. Checks the value of the variable sick? to see if the turtle is healthy C. Spreads the disease to a healthy turtle if it is sharing the patch with a sick turtle. D. Changing the color of all turtles on the patch.

Spreads the disease to a healthy turtle if it is sharing the patch with a sick turtle.

Assume you created a NetLogo world that contains 20 turtles on a green NetLogo world that has 25 randomly placed black patches. What is the result of running the above go procedure with the forever option turned on? A. Only the green turtles move around. B. The turtles move around until they land on a black patch. C. Only the black turtles move around. D. The turtles never move at all. E. The turtles move around forever.

The turtles move around until they land on a black patch.

In the code below, what does the word "other" do? A. The word "other" is a typo for "mother" B. Nothing, it is redundant C. The word "other" removes the current turtle from the agentset of turtles-here. D. The word "other" means opposite.

The word "other" removes the current turtle from the agentset of turtles-here.

You come across a code written by someone else with the following setup procedure. What will happen when you run the setup procedure? A. There will be 50 turtles, each turtle on its own patch. B. There will be 100 turtles, each on its own patch. C. There will be 50 turtles, some turtles might share a patch. D. There will be 100 turtles, exactly 2 turtles will be sharing each occupied patch.

There will be 100 turtles, exactly 2 turtles will be sharing each occupied patch.

What is the result of the above setup procedure? A. There will be 20 red turtles B. There will be 21 red turtles C. There will be 11 red turtles D. There will be 10 red turtles and 1 non-red turtle E. There will be 10 red turtles

There will be 20 red turtles

What is the result of the following code? Remember: when you create the agentset it is fixed until you change it again. A. All the turtles will die. B. There will be 10 brown patches C. There will be 10 turtles D. There will be 5 turtles on 5 brown patches

There will be 5 turtles on 5 brown patches

In NetLogo, which of the following is NOT a valid agentset? A. Three patches and a turtle with the color green. B. All the agents of the breed "rabbits" that have a "hungry" variable > 4 C. all the links between turtles with at least one friend. D. a single patch with [altitude > 5 ] E. n-of 3 turtles with [color = green]

Three patches and a turtle with the color green.

What NetLogo command is used to create a CONDITIONAL LOOP? A. Again B. Repeat C. Rerun D. While

While

In a Netlogo program, you have created a local variable list, mylist, equal to [33 44 55 66]. Which of the following is a possible result displayed in the command center for the command: A. [33 44 55 66] B. [33] C. [44] D. [55] E. [66 33]

[66 33]

Lupta wants 5 of the patches with turtles on them to grow green grass. Which code snippet below might make that happen? A. if 5 turtles-here [set pcolor green ] B. repeat 5 [ask patches with [any? turtles-here] [set color green]] C. ask 5 patches [ set pcolor green if not any? Turtles-here set pcolor black ] D. ask 5 patches with [turtles-on] [set color green] E. ask n-of 5 patches with [any? turtles-here] [set pcolor green ]

ask n-of 5 patches with [any? turtles-here] [set pcolor green ]

You have a list, mylist, that contains 10 numbers (odd numbers from 1 - 20). [ 1 3 5 7 9 11 13 15 17 19 ] You want to put a 0 in the front of the list. What is the command you would use to do that and the resulting list? A. prepend mylist 0 mylist B. lput mylist 0 mylist C. postpend mylist 0 mylist D. add mylist 0 E. fput mylist 0 mylist

fput mylist 0 mylist

Consider the NetLogo statement below, how often is my procedure called? A. myProcedure is always called. B. myProcedure is never called. C. myProcedure is called about 10% of the time. D. myProcedure is called about 1% of the time. E. myProcedure is called about 10 times.

myProcedure is called about 1% of the time.

Imagine trying to carry eggs before the invention of egg cartons. Messy. Before there were Lists programming was messy too. Lists store an ordered collections of things. They are easy to make ( let my-list [ ] ). It is not too hard to put things into them; fput lets you put things at the front of the list and lput lets you put things at the end of the list. You can always inspect what is in them, like this: show my-list. What does the following go procedure show in the command center after it is executed. A. observer: ["a" "piece" "of" "candy"] B. observer: ["candy" "of" "piece" "a"] C. observer: ["a" "piece" "of" "cake"] D. observer: ["a" "piece" "of" "rabbit"]

observer: ["a" "piece" "of" "cake"]

A reporter returns a value, which can be a number. It essentially "turns into" some value. For example, the reporter "multiply-two" is defined as shown in section A below. Then asking the turtles to set size multiply-two 2 3, would set the size of the turtle to 6. Given that information, what does line B do? A. produces an error B. redefines the reporter C. shows a 12 in the command window D. sets turtles to size 12

shows a 12 in the command window


Set pelajaran terkait

Textbook Questions (ch 59, 56, 57, 61, 62)

View Set

Homeowners- Section I. Property Coverage

View Set

Style/Syntax Terms Anadiplosis-Zeumga

View Set