Spec 2.2 and 2.3 ยท Programming

Code Tracer

Dry-run OCR Exam Reference Language in your head and predict the output โ€“ or hunt the bug.

Score 0
Streak 0
Best 0


      
Ctrl + Enter to check
Exam Reference Language quick guide
x = 5                     // assignment
const VAT = 0.2           // constant
name = input("Name?")     // input (always a string)
print("Hi " + name)       // output and concatenation
if x > 3 then โ€ฆ elseif โ€ฆ else โ€ฆ endif
switch x: case 1: โ€ฆ default: โ€ฆ endswitch
for i = 1 to 10 step 2 โ€ฆ next i
while x < 10 โ€ฆ endwhile
do โ€ฆ until x == 10
array nums = [3, 7, 1]    // arrays start at index 0
grid[1,2]                 // 2D array
word.length  word.upper  word.lower
word.substring(start, length)  word.left(n)  word.right(n)
ASC("A") โ†’ 65    CHR(65) โ†’ "A"
str(5)  int("5")  float("2.5")  bool("True")   // casting
+ - * /   ^ (power)   MOD (remainder)   DIV (whole-number division)
==  !=  <  <=  >  >=     AND  OR  NOT
function f(x) โ€ฆ return โ€ฆ endfunction
procedure p(x) โ€ฆ endprocedure
random(1, 6)              // random integer 1 to 6