LEARN · PREDICT · VERIFY
Guided Instruction
Explore how the input() function receives information and stores it in a variable.
Step 1 – Observe the program
name = input("Enter your name: ")
print("Welcome", name)Read both statements carefully. Notice that the first statement receives information, while the second statement displays information.
Step 2 – Understand each part
| Component | Explanation |
|---|---|
name | A variable that stores the information entered by the user. |
= | The assignment operator. It assigns the value received from input() to the variable. |
input() | A Python function that displays a prompt and waits for the user to enter information. |
"Enter your name: " | The prompt displayed to guide the user. It tells the user what information to enter. |
| User response | The information typed by the user after the prompt appears. |
Step 3 – Understand the sequence
- Python displays the prompt:
Enter your name:. - The program pauses and waits for the user to enter a response.
- The user types a name and presses Enter.
- The
input()function returns the entered information. - The assignment operator stores that response in the variable
name. - The
print()statement displays the welcome message using the stored value.
Important concept: The
input() function returns the information entered by the user as a string, even when the user types digits.Step 4 – Predict before execution
- What will appear when the program runs?
- What will be stored in
nameif the user entersSara? - What will the output look like after the user enters
Sara?
Think about your answers before the teacher runs the program in Python IDLE.
Step 5 – Verify an AI-generated claim
“The text inside the brackets of
input() is the information entered by the user.”Work out whether this claim is correct. Verify it by observing the program in Python IDLE.
- Identify the prompt displayed by Python.
- Identify what the user types.
- Explain the difference between the prompt and the user’s response.
Teacher consolidation: The text inside the brackets is the prompt. The user’s response is entered after the prompt appears and is returned by input().