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)
Console bridge: text in, text out · In any playground, open Reference to copy these.
Ask a question, store the typed answer, and use it in a reply.
name = input("What is your name? ")
print("Hello, " + name)
Give a value a name, so you can reuse and change it.
size = 50length = 120
forward(length)
left(90)
forward(length / 2)
Show text or a value in the output box.
print("Hello")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 pieces of text into one with +. Spaces only appear where they are inside the quotes.
"Hello, " + nameCheck 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.")text = input("How many tickets? ")
if text.isdigit():
print("That will be $" + str(int(text) * 12) + ".")
else:
print("Please type a number.")
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 + 5size = 5
for i in range(30):
forward(size)
right(90)
size = size + 5
Turn a number into text, so it can be joined: "Score: " + str(score).
str(score)