Download presentation
Presentation is loading. Please wait.
Published byMaximilian Mathews Modified over 9 years ago
1
New Mexico Computer Science For All Statements and Expressions in NetLogo Maureen Psaila-Dombrowski
2
Statements and Expressions Generally, a computer program is made up of two types of code: ▫Statements ▫Expressions
3
Statements A statement is the smallest independent unit of code Usually a statement produces an action
4
Statements in NetLogo: Commands Statements in NetLogo are called COMMANDS There are many pre-defined commands (primitives) in NetLogo Typically they begin with a verb, such as “create”, “forward”, “clear”, “hatch”.... ask turtles [ forward 1 ]
5
Expressions It is the smallest unit of calculation. Expression represents or evaluates to a value ▫Single values (values, constant or variable) ▫Combinations of values interconnected with operators (25+12, a+b, x=y+12), or functions If more than one operation occurs in an expression, the order of operations is used to determine the order they are performed in. That value is what the computer uses instead of the expression.
6
Expressions in NetLogo Similar to other programming languages Equals something (evaluates to something) ExpressionWhat it evaluates to: 12460 8+2028 28/47 sqrt 164 57 > 12true 180 < 25false
7
Summary There are two types of code: ▫Statements or Commands in NetLogo The smallest independent unit of code Produces an action ▫Expressions The smallest unit of calculation Produces (or evaluates to) a value
8
Further Information If you would like more information: ▫NetLogo Manual ▫NetLogo Dictionary
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.