Instructional Material: Statements

Printer-friendly version

Statements are the work horse construct of any text based programming language. Statements are where action happens and where you encode your algorithm into instructions for your robot. Statements fall into two categories, actions with assignment of a resulting value to a variable and actions that do not assign a result:

Note there is always only one item, a variable, on the left side of the assignment operator. You cannot have operations on the left side of the = sign: think ‘assignment’ not equals! You can control the order of operations with parenthesis:

Operators are used  to manipulate variables in a statement. Operators have an order of evaluation called precdence (more), at the same parenthetic level. In the above example, multiplication is done before addition. Watch this video up to comparison operators (discussed later). The various math operators available are discussed here and here (arithmetic and assignment sections).

Statements can span more than one line and continue until terminated with a semicolon. Statements (other than variable declarations) only appear inside methods. We will discuss methods a bit later.

Here is a quiz on variable assignment statements.


Material Type: 
Education Level: 
HW Platform: 
SW Platform: 
Interactivity Style: 
Copyright (c) 2016 by the author. All rights reserved.