1 / 6

Week 6 DO NOW QUESTIONS

Week 6 DO NOW QUESTIONS. Question: For which of the following variables would you use a global variable? Turtle color Average turtle age ID of the turtle nearest to me Turtle color Average age of all Turtles ID of the turtle nearest me

tassos
Download Presentation

Week 6 DO NOW QUESTIONS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week 6DO NOW QUESTIONS

  2. Question: For which of the following variables would you use a global variable? Turtle color Average turtle age ID of the turtle nearest to me • Turtle color • Average age of all Turtles • ID of the turtle nearest me • None of the above, they are all turtle variables

  3. Question: What is the value of the variable myCount after the setup procedure runs? to setup let myCount 0 ask patches [ set myCount (random 100) if myCount < 50 [ set pcolor red set myCountmyCount + 1 ] ] end • 101 • 100 • It depends on how many patches their are • A random number between 1 and 100

  4. Question: In the following piece of code, the programmer intended on keeping track of the total number of steps all of the turtles have taken in the variable totalSteps. What is the error in the following code segment? Turtles-own [energy] Global [totalSteps] to go-one-time set totalSteps 0 Ask-turtles [ forward 1 set energy energy - .05 set totalStepstotalSteps + 1 ] end • All of turtles are only updating their local turtle counts • The global totalSteps is not being updated by turtles • There is no error • totalSteps should start at 1 not 0

  5. Question: In the following piece of code, the programmer intended that each turtle would keep track of its energy. What is the error in the following code segment? Turtles-own [energy] to go-one-time set energy 100 Ask turtles [ forward 1 set energy energy - .05 ] end • A turtle’s energy cannot be set outside of Ask-turtles [ ] • A turtle’s energy is never being updated • There is no error • A turtle’s energy should start at 0 not 100.

  6. Question: For which of the following variables would you use a local variable using the “Let” command? Turtle color Average turtle age ID of the turtle nearest to me • Turtle color • Average age of all Turtles • ID of the turtle nearest me • All of the above, they are all turtle variables

More Related