80 likes | 364 Views
New Mexico Computer Science For All. Statements and Expressions in NetLogo Maureen Psaila-Dombrowski. Statements and Expressions. Generally, a computer program is made up of two types of code: Statements Expressions. Statements. A statement is the smallest independent unit of code
E N D
New Mexico Computer Science For All Statements and Expressions in NetLogo Maureen Psaila-Dombrowski
Statements and Expressions • Generally, a computer program is made up of two types of code: • Statements • Expressions
Statements • A statement is the smallest independent unit of code • Usually a statement produces an action
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 ]
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.
Expressions in NetLogo • Similar to other programming languages • Equals something (evaluates to something)
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
Further Information • If you would like more information: • NetLogo Manual • NetLogo Dictionary