Asking the User Questions
Interactive programs listen before they respond.
Discover
- input() asks a question and returns text.
- Store the answer in a variable.
- Never ask for private details such as a full name, address or password.
Try, explain and change
Try: Build a safe idea prompt. Ask “What should we build? ”, store the answer in project, then print “Let us build” followed by the answer. The runner supplies “space game”.
Change: Try a different project idea and check that the reply changes with it.
Try the challenge
Build a safe idea prompt. Ask “What should we build? ”, store the answer in project, then print “Let us build” followed by the answer. The runner supplies “space game”.
What should we build? Let us build space gameMatch the lines and order. Your code must use the lesson concept.
The runner supports this pathway’s controlled Python concepts while blocking packages, files, networks and system commands.
Your output will appear here.
Find the bug
project = input("What should we build? ")
print("Let us build", Project)Show debugging clue
Variable names are case-sensitive: project and Project are different.
Which question is safest?
What is your home address?
Not this time. Review Discover and try again.
What is your password?
Not this time. Review Discover and try again.
What should we build?
Correct — well reasoned.
Create and reflect
Create: Build a two-question idea generator without collecting personal information.
Reflect: Why should a program collect only the information it needs?
Ask for “robot garden” instead. Predict the reply without changing the print line.
Edit and run your code again to explore this variation. It does not change lesson completion.