Lesson 4 of 30
Lesson 04 — Ask questions with input
Title: Make Python listen and answer
Description: Use input() to ask questions and build a tiny chatbot.
Why it matters for kids: Programs become more fun when they react to the person using them.
1. Ask for a name
name = input("What is your name? ")
print(f"Hello, {name}!")
print("Nice to meet you.")The text inside input() is the question. The answer goes into name.
2. Ask about favorites
color = input("What is your favorite color? ")
animal = input("What is your favorite animal? ")
print(f"Great! A {color} {animal} would be awesome.")3. Numbers from input
input() gives text. Use int() when you need a whole number.
age_text = input("How old are you? ")
age = int(age_text)
next_age = age + 1
print(f"Next year you will be {next_age}.")4. Tiny quiz
answer = input("What is 5 + 2? ")
print(f"You typed: {answer}")
print("The correct answer is 7.")We will make smarter checks in the next lesson.
5. Easy chatbot
name = input("Name: ")
food = input("Favorite food: ")
game = input("Favorite game: ")
print()
print("Your fun card:")
print(f"Name: {name}")
print(f"Food power: {food}")
print(f"Game world: {game}")6. Mini challenge
Click each example to open it.
Example 1
Ask for a name and print hello.
Example 2
Ask for a favorite color and print it.
Example 3
Ask for a favorite food and print it.
Example 4
Ask for an animal and make a sentence.
Example 5
Ask for an age and print next age.
Example 6
Ask for a number and add 1.
Example 7
Ask for two words and join them.
Example 8
Ask for a game name and print it.
Example 9
Ask for a superhero name.
Example 10
Build a tiny profile with three answers.