🤖 Python Grade 5 · session 4 of 44 · 60 minutes · 🎁 free with an account
Talk to me: asking questions with input()
So far Bolt has done all the talking. Today Bolt listens! You will ask questions, use the answers and build your own chatbot.

A complete lesson · 60 minutes
Teach it, see it, practise it, all on this page.
Open this page with your learner and work down it, or press Teach this lesson to go through it one step at a time on a big screen. Every section has something to do.
- Warm-up3 min
- Warm-up games5 min
- input() asks a question9 min
- Turn text into numbers with int()9 min
- Build a chatbot9 min
- Mad-lib machine7 min
- Age in the future7 min
- Shopkeeper bot5 min
- Quiz5 min
- Set the after-class project1 min
By the end you can
- Ask a question with input()
- Store the answer in a box
- Turn typed numbers into real numbers with int()
- Build a chatbot that uses the answers
Before you start
- Lesson 3: variables and f-strings
Have ready
- This page
- A partner to try your chatbot
Grade 5 · ages 10 and 11 · no experience needed
Warm-up · think first
Someone types 5 and then 3 into a program, and it says the answer is 53. What went wrong?
Show the answer
The program joined them like words. To Python, anything typed in starts as text. Today you'll learn to fix that with int().
Teacher tip: Write "5" + "3" on the board and ask what happens when you glue two words together.
🎮 Warm-up games · 5 quick games
Play with Bolt the robot
Five minutes with Bolt the robot. Vote, say why, then show the answer.
- Which of these is a question a chatbot could not answer from its own memory? (What is 2 + 2? · What's your name? · How many days in a week? · What colour is grass?)
Answer: "What's your name?" is the odd one: the bot has to ask you. That's what input is for. - Would you rather have a chatbot that tells jokes, or one that does your sums? (Tells jokes · Does sums)
Answer: Either! You can build both by the end of today. - In Python, whatever you type into input() starts as text. (Always · Sometimes · Never)
Answer: Always — Always. Even if you type 5, it's the text "5" until you use int(). - What does "5" + "3" make, and what does 5 + 3 make?
Answer: "53" and 8. Text gets joined, and numbers get added. - If you could ask every person one question, what would it be?
Answer: Collect a few: they make great chatbot questions.
Three levels, like a real engineer
Use it. Tweak it. Build it.
First use what the lesson shows exactly as it is, then change one key thing and see what happens, then make your own.
- 🔒
Level 1 · Use it
Run Greeting Bot
Run this exact chatbot: name = input('What is your name? ') then print('Hello, ' + name). Type your name and press Enter. Notice how Python waits and uses your answer.
- 🔧
Level 2 · Tweak it
Change The Question
Change only the question in name = input('What is your name? ') to 'What is your favorite color? '. Before you run it, predict what word the chatbot will print. Then type blue and check.
- 🛠️
Level 3 · Build it
Make Your Chatbot
Make your own chatbot from scratch. Ask two questions with input(), store each answer, and use int() for a number like age. Print a silly sentence using both answers. Test it with a friend.
Part 1 of 3 · learn, see, practise
input() asks a question
Now it's your turn to talk! input shows a question and waits. Whatever you type goes into a box, ready to use.
input("What's your name? ") shows a question and waits for the answer.
Put the answer in a box: name = input("What's your name? "). Then use the box like any other.
On this page, type your answers in the Input box, one on each line, and then press Run.
🧑🏫 Teacher: type this live with the class
Bolt says hello to you
name = input("What is your name? ")Type a learner's name in the Input box below the code. Press Run. The box name now holds it.
print(f"Hello, {name}!")Bolt greets them by name.
pet = input("What pet would you like? ")Two questions now, so the Input box needs two lines. Add a second answer.
print(f"{name} and a pet {pet}. Great team!")Run it for a few different learners by changing the Input box.
▶ Output
(nothing is printed)
📦 Memory boxes
▶ Output
Favourite food? pizza Yum! I love pizza too.
📦 Memory boxes
'pizza'strChange pizza in the Input box and press Run again. The same code gives a new answer.
Puzzle break: ask and answer
Each puzzle shows what was typed in the Input box. Follow the answer into its box.
- Puzzle 1: say what happens before you run it
- Puzzle 2: put the lines in order
- Puzzle 3: find the bug
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
1.1 Ask "Your name? " and print exactly: Hi, (the name).
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
name = input("Your name? ")print(f"Hi, {name}")
What it prints when they type Asha
Your name? Asha Hi, Asha
What ✓ Check looks for
- When they type
Asha, the output includesHi, Asha - In the code: Use input().
1.2 Ask for a colour, then print: I like (colour) too
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
colour = input("Colour? ")print(f"I like {colour} too")
What it prints when they type red
Colour? red I like red too
What ✓ Check looks for
- When they type
red, the output includesI like red too - In the code: Use input().
1.3 Ask two questions, for a town and a food. Print: In (town) people love (food)
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 3 lines the student writes
town = input("Town? ")food = input("Food? ")print(f"In {town} people love {food}")
What it prints when they type Pune, misal
Town? Pune Food? misal In Pune people love misal
What ✓ Check looks for
- When they type
Punethenmisal, the output includesIn Pune people love misal - When they type
Goathenfish, the output includesIn Goa people love fish
1.4 Ask for a word, then print it shouted in capitals with word.upper(), like HELLO
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
word = input("Word? ")print(word.upper())
What it prints when they type hello
Word? hello HELLO
What ✓ Check looks for
- When they type
hello, the output includesHELLO - When they type
bolt, the output includesBOLT
1.5 Ask for a name, then print how many letters it has: Asha has 4 letters. Use len(name).
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
name = input("Name? ")print(f"{name} has {len(name)} letters")
What it prints when they type Asha
Name? Asha Asha has 4 letters
What ✓ Check looks for
- When they type
Asha, the output includesAsha has 4 letters - When they type
Om, the output includesOm has 2 letters - In the code: Use len(name).
🎁 Free for a year
Make a free account to open the rest of this lesson
Every new account opens every lesson of every course free for a whole year: no payment, no card, nothing to cancel.
Unlocking the rest of this lesson gives you:
- Part 2: Turn text into numbers with int(), with practice at three levels
- Part 3: Build a chatbot, with practice at three levels
- Class activity 1: Mad-lib machine
- Class activity 2: Age in the future
- Class activity 3: Shopkeeper bot
- A 8-question quiz
- After-class project: My chatbot friend
- Homework and a printable practice sheet with answers
- Teach mode and the minute-by-minute teacher's plan
It takes a minute. Anyone under 13 signs up with a parent. The first 2 lessons of every course, every game and all maths practice stay free.
FAQ
Talk to me: asking questions with input(): questions
What does input() do in Python?
It shows a question, waits for the user to type, and gives back what they typed as text.
Why does Python say ValueError with int()?
int() can only turn digits into a number. Typing a word where a number is expected causes this error.
Is a Python chatbot real AI?
Not this one. It follows the steps you wrote, which is a great way to understand how programs talk with people.
Start a conversation
Want a teacher to take this class?
Tell us the learner's age and level. A teacher from our network teaches with these lessons; we confirm timing and price first.
- Tell us the learner’s age or grade and goals
- We’ll suggest a suitable class or learning path
- We’ll confirm format, timing and fees with a parent or guardian