# Week 7 DO NOW QUESTIONS. Question: In the following segment of code, “food-location” is a ___? breed [ foragers forager ] breed [ followers follower ]

## Presentation on theme: "Week 7 DO NOW QUESTIONS. Question: In the following segment of code, “food-location” is a ___? breed [ foragers forager ] breed [ followers follower ]"— Presentation transcript:

Week 7 DO NOW QUESTIONS

Question: In the following segment of code, “food-location” is a ___? breed [ foragers forager ] breed [ followers follower ] foragers-own [ food-location food-distance food-found? ] followers-own [ foragers-food-location forager-distance ] a)Local variable b)Global variable c)Turtle variable d)None of the above, they are patch variables

Question: What is the result of running the following setup procedure ? to setup create-turtles 10 [ set color red ] ask turtles [ hatch 1 ] end a)There will be 10 red turtles b)There will be 20 red turtles c)There will be 11 turtles d)There will be 10 red turtles and 1 non-red turtle

Question: In the following piece of code, the programmer wants each of the 10 turtles already created to hatch a single offspring. Does this go-forever procedure do what she wants? to setup create-turtles 10 end to go-forever ask turtles [ hatch 1 [ set color red ] end a)No, the turtles will reproduce forever. b)No, only 1 new turtle will be created. c)Maybe, it depends on how many turtles were created to begin with. d)Yes, 20 turtles will be created.

Question: In the following piece of code, the programmer wants turtles to reproduce if they have an energy greater than 10. Will this piece of code do what the programmer intends? Turtles-own [energy] to go-one-time set energy 0 Ask turtles [ forward 10 set energy energy -.05 if energy < 0 [ die ] if energy > 10 [hatch 1] ] end a)Yes, turtles will give birth if they have enough energy b)No, the turtles will all die before giving birth c)No, it should say if “energy > 9” d)No, it should say if “energy = 10”

Question: In the following piece of code, the programmer wants turtles to reproduce if they have more energy of greater than 100. Will this piece of code do what the programmer intends? Turtles-own [energy] to setup clear-all create-turtles 10 [set energy 100] end to go-one-time Ask turtles [ forward 1 set energy energy -.05 if pcolor = green [ set energy energy +.1 ] if energy > 100 [ hatch 1 ] ] end a)A turtle’s energy cannot be set outside of Ask-turtles [ ] b)A turtle’s energy is never being updated c)There is no error d)A turtle’s energy should start at 0 not 100.

Download ppt "Week 7 DO NOW QUESTIONS. Question: In the following segment of code, “food-location” is a ___? breed [ foragers forager ] breed [ followers follower ]"

Similar presentations