Kids Coding

Ask a Question

input() waits for a typed answer. Save it. Print it back.

KidsBasicAsk a Question

Ask, then use the answer

input() waits for someone to type. What they type comes back as a string. Save it in a variable.

In the browser editor, input() can be awkward. Practice with a saved answer first. Same idea: a string in a box.

A saved answer (runs here)

name = "Sam"
print("Hello, " + name)

The real input() line

When you run Python on a computer, or when the editor asks you, this is the shape:

Ask for a name

name = "Sam"
# On a computer you can write:
# name = input("What is your name? ")
print("Nice to meet you, " + name)

input("What is your name? ") shows the question, then waits. The space at the end keeps the typing off the question.

Answers are strings

Even if someone types 7, input() gives you the string "7". For maths, convert with int("7").

A number from text

typed = "7"
age = int(typed)
print("Next year:", age + 1)

Real life

Asking a friend what pizza they want.

You wait for an answer, then use it. That is input — here the answer is already saved so it runs in the editor.

Pizza order

friend = "Riley"
pizza = "mushroom"
print(friend + " wants " + pizza + " pizza.")
print("Coming right up.")

Change one word. Run it. That is how this idea shows up outside the lesson.

Try it

Exercise 1: Put a colour in a variable called colour. Print I like and that colour.

Show solution
colour = "blue"
print("I like " + colour)

FAQ: Ask a Question

Common questions about this page.

What is StudyGrid Kids?

StudyGrid Kids is a free coding path for children: Basic, Intermediate, and Advanced. Lessons use Python in the browser. No account and no install.

Should I run ask a question examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn ask a question in this Kids Coding Python lesson (Ask a Question).

Which kids level should we start with?

Start at Basic if the child has never written code. Choose Intermediate if they can print, use variables, and write a simple if. Choose Advanced if they already use loops and lists.

Do kids need an account or an app?

No. Kids pages are public. Code runs in the Try Python editor at /try. We do not ask children for a name or an email.

What language do kids learn?

Python, with a first HTML page in Intermediate and Advanced. After Advanced, the main Python tutorial is the next step.

Is the kids coding track free?

Yes. The Kids home, the three levels, and the Python editor on StudyGrid (studygrid.in) are free.