Card 3: Input
Module 1: The Basics
1 The Hook
If print() is the Megaphone (Output), then
input() is the Microphone (Input).
It pauses the program and opens a "listening ear" to wait for the user to type something. Whatever they type gets stored in a variable.
2 Worked Example
See how we ask a question and save the answer.
PREDICT
If I type "Red", what happens?
print("I like " + color)
Input Required
Interactive Editor
🥉 Change the Question
1. Copy the code below.
2. Change the question to ask for their Favourite Food (instead of City).
3. Change the print message to say "I love [food] too!".
print("I visited " + city)
🥈 Broken Input
The code below is trying to store the input into the variable name, but it's
written backwards.
Task: Fix it.
🥇 Security System
Build a simple security checker using 2 inputs:
- Ask for
"Enter New PIN: "and store inpin1. - Ask for
"Confirm PIN: "and store inpin2. - Print
"System Armed"at the end.