Variables
Output so far
Read the code, predict the result, then choose an answer. Check the explanation before continuing. Lists start at 1.
These are practice indicators based on your recent first tries — not a prediction of test results. Progress is saved in this browser only.
Variables
Output so far
| a ← 5 | Store 5 in the variable a |
| DISPLAY(a) | Show a's value, followed by a space |
| a / b | Ordinary division: 17 / 5 is 3.4 |
| a MOD b | The remainder: 17 MOD 5 is 2 (same precedence as * and /) |
| = ≠ < > ≤ ≥ | Compare two values (true or false) |
| AND OR NOT | Combine or flip true/false values |
| IF (c) … ELSE … | Run the first block if c is true, otherwise the second |
| REPEAT n TIMES | Run the block exactly n times |
| REPEAT UNTIL (c) | Check c before each pass; stop as soon as c is true |
| FOR EACH x IN list | Run the block once for each item, first to last |
| list[1] | The FIRST item — lists start at 1. Index < 1 or > LENGTH is an error |
| APPEND(list, v) | Add v to the end |
| INSERT(list, i, v) | Put v at index i; later items shift right |
| REMOVE(list, i) | Delete the item at index i; later items shift left |
| LENGTH(list) | How many items are in the list |
| RETURN(x) | Send x back from a procedure and stop it immediately |
| RANDOM(a, b) | A random whole number from a to b, including both |
Robot: MOVE_FORWARD() moves one square the way the robot faces. ROTATE_LEFT() and ROTATE_RIGHT() turn it 90° in place. CAN_MOVE("left"), ("right"), ("forward") or ("backward") checks the square on that sideof the robot. If the robot tries to move into a blocked square or off the grid, it stays where it is and the program ends.
Keys: 1–4 choose an answer · Enter or N next question · T show or hide the trace.
Your browser isn't letting this page save progress, so it will reset when you leave.
For Teachers