15 Statements and Looping
15.1 Comparison Operators
Comparison operators test a relationship between two values and return TRUE or FALSE. They’re the building blocks of filtering a dataset — e.g. “keep only the fields where yield exceeded 4 t/ha.”
15.2 Logical Operators
-
&— AND (both conditions must be true) -
|— OR (at least one condition must be true) -
!— NOT (negates a condition)
15.3 for Loops
A for loop repeats a block of code once for each element in a sequence — useful for running the same check across every field in a season’s data.
15.4 while Loops
A while loop repeats a block of code as long as a condition remains true — useful when you don’t know in advance how many iterations you’ll need, such as simulating water accumulation until an irrigation threshold is reached.
Summary
| Concept | Description |
|---|---|
| Statements and Looping | |
| Comparison Operators | `==`, `!=`, `>`, `<`, `>=`, `<=` — test a relationship between two values. |
| Logical Operators | `&` (AND), `|` (OR), `!` (NOT) — combine or negate conditions. |
| for Loops | Repeat a block of code once per element of a known sequence, e.g. once per field. |
| while Loops | Repeat a block of code while a condition holds, useful when the number of iterations isn't known in advance. |