CurriculumPython input() and Type Conversion for KidsThe Dragon's Three Questions
Practice Challenge: Three Questions with Python input()
input(), int(), and choosing which answers actually need converting — all at once.
The Dragon's Three Questions
You've learned three things about talking to the player. Let's put them together.
One: input() asks and really waits for an answer, which always arrives as text.
Two: int() converts that text into a real number you can do math with.
Three: forgetting int() before adding or comparing crashes with a real TypeError — Python's honest way of saying 'this is still text'.
The challenge ahead asks three questions. Some answers need int(), one doesn't — figuring out which is the whole point.
Check your understanding
You ask for a player's NAME with input(). Do you need int() before printing it?
name = input("Name? ")
print(name)Why: No int() needed here — a name is used as text, not a number. int() only matters when you're about to do math with the answer.
What you'll practice
Ask "How many gems? " and print TREASURE! if the number is 10 or more, otherwise print KEEP LOOKING. The player will type 15.
More from this topic
The Dragon's Three Questions is one lesson inside Python input() and Type Conversion for Kids — see the full lesson order and what the whole topic covers.
View the full topic →