← Reference

Text in, text out: cheat sheet

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

ask and reply

Ask a question, store the typed answer, and use it in a reply.

name = input("What is your name? ")
print("Hello, " + name)
What it draws
Asks for a name, then says hello

variable

Give a value a name, so you can reuse and change it.

size = 50
Example
length = 120
forward(length)
left(90)
forward(length / 2)
What it draws
length = 120, then half of it

print

Show text or a value in the output box.

print("Hello")

input

Show a question in the console, wait for an answer, and store what was typed. It is always text.

name = input("What is your name? ")

join text

Join pieces of text into one with +. Spaces only appear where they are inside the quotes.

"Hello, " + name

check then convert

Check typed text with isdigit before turning it into a number.

text = input("How many? ")
if text.isdigit():
    number = int(text)
    pass
else:
    print("Please type a number.")
Example
text = input("How many tickets? ")
if text.isdigit():
    print("That will be $" + str(int(text) * 12) + ".")
else:
    print("Please type a number.")
What it draws
A checked ticket total

grow value

Change a value every pass: read the old one, store a new one.

size = 5
for i in range(20):
    forward(size)
    right(90)
    size = size + 5
Example
size = 5
for i in range(30):
    forward(size)
    right(90)
    size = size + 5
What it draws
The same spiral, grown by an update

str

Turn a number into text, so it can be joined: "Score: " + str(score).

str(score)