Skip to content

Latest commit

 

History

History
3233 lines (3087 loc) · 69.9 KB

SEMANTICS.md

File metadata and controls

3233 lines (3087 loc) · 69.9 KB

Semantics

This page is a first try at describing the semantics of Hedy. Because Hedy code is transpiled into Python, we define the semantics of an Hedy program in terms of the semantics of the resulting Python code, or, in case of an error, the resulting HedyException.

Level 1

Commands and types

Level 1 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn 'right' + integer | 'left' + integer | empty
echo integer | string | empty

Correct Programs

Hedy Python
print x y print('x y')
forward t = turtle.Turtle()
t.forward(50)
forward 100 t = turtle.Turtle()
t.forward(100)
turn t = turtle.Turtle()
t.right(90)
turn left t = turtle.Turtle()
t.left(90)
turn right t = turtle.Turtle()
t.right(90)
turn 100 t = turtle.Turtle()
t.right(100)
ask x answer = input('x')
ask x
echo y
answer = input('x')
print('y', answer)

Incorrect Programs

Hedy Exception
print Incomplete Exception
ask Incomplete Exception
(forward | turn) text Invalid Argument Type Exception
(not (print | ask | forward | turn | echo)) (any text)? Invalid Exception
any valid line(s) of code not using ask
echo x
Lonely Echo
_SPACE (print | ask | forward | turn | echo) (any text)? Invalid space

Level 2

Commands and types

Level 2 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer

Correct Programs

Hedy Python
print x y print('x y')
forward t = turtle.Turtle()
t.forward(50)
forward 100 t = turtle.Turtle()
t.forward(100)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 100 t = turtle.Turtle()
t.right(100)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
x is 90
print x
x = '90'
print(x)
x is ask y
print x
x = input('y')
print(x)
sleep time.sleep(1)
sleep 1 time.sleep(1)

Incorrect Programs

Hedy Exception
print Incomplete Exception
ask Incomplete Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception

Level 3

Commands and types

Level 3 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list

Correct Programs

Hedy Python
print x y print('x y')
forward t = turtle.Turtle()
t.forward(50)
forward 50 t = turtle.Turtle()
t.forward(50)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 90 t = turtle.Turtle()
t.right(90)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
sleep time.sleep(1)
sleep 1 time.sleep(1)
ask x answer = input('x')
x is ask y
print x
x = input('y')
print(x)
x is a, b, c
(turn | forward) x at random
x = ['a', 'b', 'c']
t = turtle.Turtle()
t.right(random.choice(x))
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass

Incorrect Programs

Hedy Exception
print Incomplete Exception
ask Incomplete Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
items is (text without a comma)
print items at random
Invalid Argument Type Exception

Level 4

Commands and types

Level 4 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
forward t = turtle.Turtle()
t.forward(50)
forward 50 t = turtle.Turtle()
t.forward(50)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 90 t = turtle.Turtle()
t.right(90)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass

Incorrect Programs

Hedy Exception
print Incomplete Exception
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
items is (text without a comma)
print items at random
Invalid Argument Type Exception

Level 5

Commands and types

Level 5 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
forward t = turtle.Turtle()
t.forward(50)
forward 50 t = turtle.Turtle()
t.forward(50)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 90 t = turtle.Turtle()
t.right(90)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy print 'great' else print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 1 2
one is 1
if one in a print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name print 'found'
Invalid Argument Type Exception

Level 6

Commands and types

Level 6 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{int(1) + int(1)}')
print 1 - 1 print(f'{int(1) - int(1)}')
print 1 * 1 print(f'{int(1) * int(1)}')
print 1 / 1 print(f'{int(1) / int(1)}')
a is 1
print a
a = '1'
print(f'{a}')
forward t = turtle.Turtle()
t.forward(50)
forward 50 t = turtle.Turtle()
t.forward(50)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 90 t = turtle.Turtle()
t.right(90)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy print 'great' else print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1.0 + 1 Unsupported decimal number
print 1,0 + 1 Unsupported decimal number
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name print 'found'
Invalid Argument Type Exception

Level 7

Commands and types

Level 7 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean
repeat integer + 'times'

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{int(1) + int(1)}')
print 1 - 1 print(f'{int(1) - int(1)}')
print 1 * 1 print(f'{int(1) * int(1)}')
print 1 / 1 print(f'{int(1) / int(1)}')
a is 1
print a
a = '1'
print(f'{a}')
forward t = turtle.Turtle()
t.forward(50)
forward 50 t = turtle.Turtle()
t.forward(50)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 90 t = turtle.Turtle()
t.right(90)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy print 'great' else print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
repeat 3 times print 'hello!' for i in range(int('3')):
  print(f'hello!')
n is 3
repeat n times print 'hello!'
n = '3'
for i in range(int(n)):
  print(f'hello!')

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1.0 + 1 Unsupported decimal number
print 1,0 + 1 Unsupported decimal number
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name print 'found'
Invalid Argument Type Exception

Level 8

Commands

Level 8 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean
repeat integer + 'times'

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{int(1) + int(1)}')
print 1 - 1 print(f'{int(1) - int(1)}')
print 1 * 1 print(f'{int(1) * int(1)}')
print 1 / 1 print(f'{int(1) / int(1)}')
a is 1
print a
a = '1'
print(f'{a}')
forward t = turtle.Turtle()
t.forward(50)
forward 50 t = turtle.Turtle()
t.forward(50)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 90 t = turtle.Turtle()
t.right(90)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items
  print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
repeat 3 times
  print 'hello!'
for i in range(int('3')):
  print(f'hello!')
n is 3
repeat n times
  print 'hello!'
n = '3'
for i in range(int(n)):
  print(f'hello!')

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1.0 + 1 Unsupported decimal number
print 1,0 + 1 Unsupported decimal number
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a
  print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name
  print 'found'
Invalid Argument Type Exception
repeat 3 times print 'hello!' Invalid command (TODO: this has to be improved)

Level 9

Commands and types

Level 9 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean
repeat integer + 'times'

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{int(1) + int(1)}')
print 1 - 1 print(f'{int(1) - int(1)}')
print 1 * 1 print(f'{int(1) * int(1)}')
print 1 / 1 print(f'{int(1) / int(1)}')
a is 1
print a
a = '1'
print(f'{a}')
forward t = turtle.Turtle()
t.forward(50)
forward 50 t = turtle.Turtle()
t.forward(50)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 90 t = turtle.Turtle()
t.right(90)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items
  print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
repeat 3 times
  print 'hello!'
for i in range(int('3')):
  print(f'hello!')
n is 3
repeat n times
  print 'hello!'
n = '3'
for i in range(int(n)):
  print(f'hello!')

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1.0 + 1 Unsupported decimal number
print 1,0 + 1 Unsupported decimal number
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a
  print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name
  print 'found'
Invalid Argument Type Exception
repeat 3 times print 'hello!' Invalid command (TODO: this has to be improved)

Level 10

Commands and types

Level 10 supports:

Command Types
print integer | string
ask integer | string
forward integer | empty
turn integer | empty
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean
repeat integer + 'times'
for string + 'in' + list

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{int(1) + int(1)}')
print 1 - 1 print(f'{int(1) - int(1)}')
print 1 * 1 print(f'{int(1) * int(1)}')
print 1 / 1 print(f'{int(1) / int(1)}')
a is 1
print a
a = '1'
print(f'{a}')
forward t = turtle.Turtle()
t.forward(50)
forward 50 t = turtle.Turtle()
t.forward(50)
a is 50
forward a
a = '50'
t = turtle.Turtle()
t.forward(a)
turn t = turtle.Turtle()
t.right(90)
turn 90 t = turtle.Turtle()
t.right(90)
a is 50
turn a
a = '50'
t = turtle.Turtle()
t.right(a)
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items
  print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
repeat 3 times
  print 'hello!'
for i in range(int('3')):
  print(f'hello!')
n is 3
repeat n times
  print 'hello!'
n = '3'
for i in range(int(n)):
  print(f'hello!')
ns is 1, 2, 3
for n in ns
  print n
ns = ['1', '2', '3']
for n in ns:
  print(f'{n}')

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1.0 + 1 Unsupported decimal number
print 1,0 + 1 Unsupported decimal number
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask | forward | turn)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask | forward | turn) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
(forward | turn) text Invalid Argument Type Exception
a is text
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
(forward | turn) a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a
  print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name
  print 'found'
Invalid Argument Type Exception
repeat 3 times print 'hello!' Invalid command (TODO: this has to be improved)

Level 11

Commands and types

Level 11 supports:

Command Types
print integer | string
ask integer | string
is string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean
repeat integer + 'times'
for string + 'in' + list | string + 'in' + 'range' + integer + 'to' + integer

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{int(1) + int(1)}')
print 1 - 1 print(f'{int(1) - int(1)}')
print 1 * 1 print(f'{int(1) * int(1)}')
print 1 / 1 print(f'{int(1) / int(1)}')
a is 1
print a
a = '1'
print(f'{a}')
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = ['1', '2', '3']
f = '4'
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = ['1', '2', '3']
f = '4'
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items
  print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
ns is 1, 2, 3
for n in ns
  print n
ns = ['1', '2', '3']
for n in ns:
  print(f'{n}')
for a in range 2 to 4
  a is a + 2
step = 1 if int(2) < int(4) else -1
for a in range(int(2), int(4) + step, step):
  a = int(a) + int(2)

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1.0 + 1 Unsupported decimal number
print 1,0 + 1 Unsupported decimal number
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a
  print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name
  print 'found'
Invalid Argument Type Exception
for a in range 1 to 10
print 'hello!'
No Indentation Exception

Level 12

Commands and types

Level 12 supports:

Command Types
print integer | string | float
ask integer | string | float
is | = string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean
repeat integer + 'times'
for string + 'in' + list | string + 'in' + 'range' + integer + 'to' + integer

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{1 + 1}')
print 1 - 1 print(f'{1 - 1}')
print 1 * 1 print(f'{1 * 1}')
print 1 / 1 print(f'{1 / 1}')
print 1.0 + 1 print(f'{1.0 / 1}')
a is 1
print a
a = 1
print(f'{a}')
a is 1.0
print a
a = 1.0
print(f'{a}')
a is 'text'
print a
a = 'text'
print(f'{a}')
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
try:
  x = int(x)
except ValueError:
  x = float(x)
  except ValueError:
    pass
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = [1, 2, 3]
f = 4
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = [1, 2, 3]
f = 4
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = [1, 2, 3]
f = 4
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items
  print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
ns is 1, 2, 3
for n in ns
  print n
ns = [1, 2, 3]
for n in ns:
  print(f'{n}')
for a in range 2 to 4
  a is a + 2
step = 1 if int(2) < int(4) else -1
for a in range(int(2), int(4) + step, step):
  a = a + 2

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1,0 + 1 Invalid Command (TODO: this could be improved)
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a
  print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name
  print 'found'
Invalid Argument Type Exception
for a in range 1 to 10
print 'hello!'
No Indentation Exception

Level 13

Commands and types

Level 13 supports:

Command Types
print integer | string | float
ask integer | string | float
is | = string (before `is`) + any (after `is`)
sleep empty | integer
at random list
add to list
remove from list
if boolean
if else boolean
repeat integer + 'times'
for string + 'in' + list | string + 'in' + 'range' + integer + 'to' + integer
and boolean (before `and`) + boolean (after `and`)
or boolean (before `or`) + boolean (after `or`)

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{1 + 1}')
print 1 - 1 print(f'{1 - 1}')
print 1 * 1 print(f'{1 * 1}')
print 1 / 1 print(f'{1 / 1}')
print 1.0 + 1 print(f'{1.0 / 1}')
a is 1
print a
a = 1
print(f'{a}')
a is 1.0
print a
a = 1.0
print(f'{a}')
a is 'text'
print a
a = 'text'
print(f'{a}')
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
try:
  x = int(x)
except ValueError:
  x = float(x)
  except ValueError:
    pass
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = [1, 2, 3]
f = 4
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = [1, 2, 3]
f = 4
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = [1, 2, 3]
f = 4
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
name is Hedy
if name is hedy (or | and) name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if str(name) == str('Hedy') (or | and) str(name) == str('hedy'):
  print(f'great')
else:
  print(f'fine')
items is red, green
selected is red
if selected in items
  print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
ns is 1, 2, 3
for n in ns
  print n
ns = [1, 2, 3]
for n in ns:
  print(f'{n}')
for a in range 2 to 4
  a is a + 2
step = 1 if int(2) < int(4) else -1
for a in range(int(2), int(4) + step, step):
  a = a + 2

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1,0 + 1 Invalid Command (TODO: this could be improved)
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a
  print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name
  print 'found'
Invalid Argument Type Exception
for a in range 1 to 10
print 'hello!'
No Indentation Exception

Level 14

Commands

Level 14 supports:

  • print
  • ask
  • is
  • sleep
  • at random
  • add to
  • remove from
  • if
  • if else
  • repeat
  • for

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{1 + 1}')
print 1 - 1 print(f'{1 - 1}')
print 1 * 1 print(f'{1 * 1}')
print 1 / 1 print(f'{1 / 1}')
print 1.0 + 1 print(f'{1.0 / 1}')
a is 1
print a
a = 1
print(f'{a}')
a is 1.0
print a
a = 1.0
print(f'{a}')
a is 'text'
print a
a = 'text'
print(f'{a}')
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
try:
  x = int(x)
except ValueError:
  x = float(x)
  except ValueError:
    pass
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = [1, 2, 3]
f = 4
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = [1, 2, 3]
f = 4
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = [1, 2, 3]
f = 4
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
name is Hedy
if name is hedy (or | and) name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if str(name) == str('Hedy') (or | and) str(name) == str('hedy'):
  print(f'great')
else:
  print(f'fine')
a is 1
if a (< | <= | > | >= | !=) 2
  print a
a = 1
if str(a).zfill(100) (< | <= | > | >= | !=) str('2').zfill(100):
  print(f'{a}')
items is red, green
selected is red
if selected in items
  print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
ns is 1, 2, 3
for n in ns
  print n
ns = [1, 2, 3]
for n in ns:
  print(f'{n}')
for a in range 2 to 4
  a is a + 2
step = 1 if int(2) < int(4) else -1
for a in range(int(2), int(4) + step, step):
  a = a + 2

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1,0 + 1 Invalid Command (TODO: this could be improved)
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a
  print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name
  print 'found'
Invalid Argument Type Exception
if '1' < 3
  print 'true'
Invalid Argument Type Exception
for a in range 1 to 10
print 'hello!'
No Indentation Exception

Level 15

Commands

Level 15 supports:

  • print
  • ask
  • is
  • sleep
  • at random
  • add to
  • remove from
  • if
  • if else
  • repeat
  • for
  • while

Correct Programs

Hedy Python
print 'x' 'y' print('xy')
print 1 + 1 print(f'{1 + 1}')
print 1 - 1 print(f'{1 - 1}')
print 1 * 1 print(f'{1 * 1}')
print 1 / 1 print(f'{1 / 1}')
print 1.0 + 1 print(f'{1.0 / 1}')
a is 1
print a
a = 1
print(f'{a}')
a is 1.0
print a
a = 1.0
print(f'{a}')
a is 'text'
print a
a = 'text'
print(f'{a}')
sleep time.sleep(1)
sleep 1 time.sleep(1)
x is ask 'y'
print x
x = input('y')
try:
  x = int(x)
except ValueError:
  x = float(x)
  except ValueError:
    pass
print(x)
x is a, b, c
print x at random
x = ['a', 'b', 'c']
print(random.choice(x))
a is 1, 2, 3
f is 4
add f to a
a = [1, 2, 3]
f = 4
a.append(f)
a is 1, 2, 3
f is 4
remove f from a
a = [1, 2, 3]
f = 4
try:
  a.remove(f)
except:
  pass
a is 1, 2, 3
f is 4
remove f from a
a = [1, 2, 3]
f = 4
try:
  a.remove(f)
except:
  pass
name is Hedy
if name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if name == 'Hedy':
  print(f'great')
else:
  print(f'fine')
name is Hedy
if name is hedy (or | and) name is Hedy
  print 'great'
else
  print 'fine'
naam = 'Hedy'
if str(name) == str('Hedy') (or | and) str(name) == str('hedy'):
  print(f'great')
else:
  print(f'fine')
a is 1
if a (< | <= | > | >= | !=) 2
  print a
a = 1
if str(a).zfill(100) (< | <= | > | >= | !=) str('2').zfill(100):
  print(f'{a}')
items is red, green
selected is red
if selected in items
  print 'found!'
items = ['red', 'green']
selected = 'red'
if selected in items:
  print(f'found!')
ns is 1, 2, 3
for n in ns
  print n
ns = [1, 2, 3]
for n in ns:
  print(f'{n}')
for a in range 2 to 4
  a is a + 2
step = 1 if int(2) < int(4) else -1
for a in range(int(2), int(4) + step, step):
  a = a + 2
a is 0
while a < 3
  a is a + 1
a = 0
while str(a).zfill(100)<str(3).zfill(100):
  a = a + 1

Incorrect Programs

Hedy Exception
print Incomplete Exception
print'x' Invalid command
print 1,0 + 1 Invalid Command (TODO: this could be improved)
ask Incomplete Exception
(ask | print) (any text without quotes around it) Unquoted Text Exception
(not (print | ask)) (any text) (not is) (any text)? Invalid Exception
_SPACE (print | ask) (any text)? Invalid space
_SPACE (any text) is (any text)? Invalid space
a is 1, 2, 3
answer is ask 'Is the number in ' a
Invalid Argument Type Exception
a is 1, 2, 3
f is 4
(add | remove) a (to | from) f
Invalid Argument Type Exception
items is 1, 2, 3
print items
Invalid Argument Type Exception
a is 'test'
print a + 1
Invalid Argument Type Exception
a is 'text'
one is 1
if one in a
  print 'found!'
Invalid Argument Type Exception
name is 1, 2
if '1' is name
  print 'found'
Invalid Argument Type Exception
if '1' < 3
  print 'true'
Invalid Argument Type Exception
for a in range 1 to 10
print 'hello!'
No Indentation Exception