← Teacher guide Markdown for Prepare

Menus and testing: cheat sheet

Console bridge: text in, text out · In any playground, open Reference to copy these.

menu loop

A menu that keeps showing until a break runs.

while True:
    choice = input("1 add, 2 quit: ")
    if choice == "1":
        pass
    elif choice == "2":
        break
    else:
        print("Please choose 1 or 2.")

break

Leave the loop straight away; the program carries on after it.

break

def (function)

Name a group of steps, then run it by calling its name.

def shape():
    pass

shape()
Example
def zigzag():
    left(45)
    forward(30)
    right(90)
    forward(30)
    left(45)

zigzag()
zigzag()
zigzag()
What it draws
Defined once, called three times