๐ Python for beginners ยท session 4 of 58 ยท 60 minutes ยท ๐ free with an account
Talking to the user: input() and types
Programs become fun when they talk to you. Ask a question with input(), turn the answer into a number, and build programs that work for any answer, practising each step as you go.

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-up4 min
- Asking a question7 min
- Text or number?9 min
- Convert straight away8 min
- Calculators7 min
- Age in 20408 min
- Pizza planner8 min
- Story machine5 min
- Quiz3 min
- Set the project1 min
By the end you can
- Ask a question with input() and store the answer
- Explain why input() always gives text
- Convert with int(), float() and str()
- Build calculators and planners that work for any input
Before you start
- Session 2: variables and f-strings
Have ready
- This page (type answers in the Input box under each editor, one per line)
Beginner ยท ages 10 and up
Warm-up ยท think first
A form asks "How old are you?" and you type 11. Then it asks "How old will you be in 5 years?" Can the computer add 5 to what you typed straight away? What might go wrong?
Show the answer
What you type arrives as text, like a word. Adding 5 to the word "11" makes no sense, so the program must first turn the text into a number.
Teacher tip: Write "11" and 11 on paper: which is a word made of characters, and which is a number you can add to?
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
Use It Greeter
Run this exact program: name = input('What is your name? ') then print('Hello, ' + name). Type your name and notice what the computer says back.
- ๐ง
Level 2 ยท Tweak it
Tweak It Colours
Change the question text in input('What is your name? ') to 'What is your favourite colour? ' and change 'Hello, ' to 'Nice colour, '. Predict what changes, then run it.
- ๐ ๏ธ
Level 3 ยท Build it
Build It Calculator
Make your own age-in-10-years calculator. Ask for age with input(), convert it using int(), then print the age plus 10. Test it with your age and a friend's age.
Part 1 of 4 ยท learn, see, practise
Asking a question
input("question") shows the question, waits for an answer and gives it back. Store it in a variable.
On this page, type answers in the Input box, one per line, then press Run. The program takes the next line each time it asks.
โถ Output
What is your name? Asha Hello, Asha! Nice to meet you.
๐ฆ Memory boxes
'Asha'strChange Asha to your name and run again.
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 for a name and print Welcome, <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"Welcome, {name}!")
What it prints when they type Mia
Name? Mia Welcome, Mia!
What โ Check looks for
- When they type
Mia, the last line it prints isWelcome, Mia! - When they type
Om, the last line it prints isWelcome, Om!
1.2 Ask for a colour, then an animal. Print: Your <colour> <animal> is ready.
โถ 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
c = input("Colour? ")a = input("Animal? ")print(f"Your {c} {a} is ready.")
What it prints when they type red, dragon
Colour? red Animal? dragon Your red dragon is ready.
What โ Check looks for
- When they type
redthendragon, the last line it prints isYour red dragon is ready. - When they type
bluethenwhale, the last line it prints isYour blue whale is ready.
1.3 Ask for three words, then print them in reverse order on one line, separated by spaces.
โถ 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 4 lines the student writes
a = input("1? ")b = input("2? ")c = input("3? ")print(c, b, a)
What it prints when they type one, two, three
1? one 2? two 3? three three two one
What โ Check looks for
- When they type
onethentwothenthree, the last line it prints isthree two one - When they type
athenbthenc, the last line it prints isc b a
๐ 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: input() always gives text, with practice at three levels
- Part 3: Convert straight away, with practice at three levels
- Part 4: Calculators that work for anyone, with practice at three levels
- Class activity 1: Age in the year 2040
- Class activity 2: Pizza party planner
- Class activity 3: Story machine
- A 8-question quiz
- After-class project: Unit converter
- 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
Talking to the user: input() and types: questions
Why does Python input() return a string?
The keyboard sends characters, so input gives text and you convert it with int() or float().
How do I read a number from the user in Python?
Wrap input in int() or float(): age = int(input("Age? ")).
How does the Input box work on this page?
Each line is one answer, used in order whenever the program asks.
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