a = 5
b = 3
c = 1
point("north")
forward(a)
forward(b)
forward(c)
total = a + b + c
mean = total / 3
point("east")
forward(mean)
dig()
x = 2
steps = (x + x) * x
IF steps<=10:
steps = steps + x
ELSE:
steps = steps - 2 * x
END IF
point("north")
forward(steps)
point("west")
forward(x)
dig()
steps = 2^2
steps = steps * 3
IF steps>=0 AND steps<10:
direction = "north"
ELIF steps>=10 AND steps<20:
direction = "west"
ELSE:
direction = "east"
EnD IF
point(direction)
forward(steps/3)
point("north")
forwards(steps/4)
dig()
steps = 0
FOR i FROM 1 to 5:
steps = steps + 2
NEXT i
point("north")
forward(steps)
FOR i FROM 1 to 5:
steps = steps - 1
NEXT i
point("west")
forward(steps)
dig()
point("west")
forward(5)
FOR x FROM 1 TO 5:
point("north")
forward(2)
point("east")
forward(2)
NEXT i
dig()
steps = 240
WHILE steps>20:
steps = steps / 2
END WHILE
point("north")
forward(steps/3)
point("east")
forward(steps/5)
dig()
x = 1
steps = 0
point("north")
WHILE x<=5:
IF x==5:
point("east")
END IF
forward(x)
x = x + 1
END WHILE
dig()
point("north")
total = 0
FOR x FROM 1 TO 4:
forward(x)
total = total + x
NEXT x
point("south")
forward(total)
dig()
FOR i FROM 1 TO 4:
point("east")
FOR j FROM 1 TO 2:
forward(1)
NEXT j
point("north")
forward(3)
NEXT i
dig()
Arithmetic Operators
+ means add: 2 + 3 = 5
- means subtract: 3 - 2 = 1
* means multiply: 2 * 3 = 6
/ means divide: 6 / 3 = 2
^ means "to the power of": 3^2 = 9
Comparison Operators
== means is equal to e.g. 4==4
!= means is not equal to e.g. 3!=4
< means is lower than e.g. 2<3
> means is greater than. e.g. 5>1
>= means is greater or equal to e.g. 5>=1 and 5>=5
<= means is lower or equal to e.g. 2<=3 and 2<=2