How Do Programs Talk to Us?
"One of the ways that we can present information is through printing items to the console. One of the ways to make our programs dynamic is by allowing our users to add their own data."
The Two-Way Conversation
print()
Program responds
←
Interactive Example
The Critical Pitfall: Storing Input
Common Mistake: Getting input but not storing it in a variable means the data disappears!
# ❌ WRONG - Data vanishes
input("Enter your name: ")
print(name) # Error! What is name?
# ✅ CORRECT - Store in variable
name = input("Enter your name: ")
print(name) # Works!
Casting: Converting Types
"The default type of information from input() is a string. If we're expecting a number, we have to convert it."
# Input always returns strings
age = input("Age: ") # User types "25"
# age is "25" (string) not 25 (number)
# Cast to integer to do math
age = int(input("Age: "))
# Now age is 25 (number)
# Cast back to string
age_text = str(age) # "25" (string)
Mental Model: Input/Output is like passing notes. You write something (input), pass it to the program, the program writes back (output). But you need to keep the note (store in variable) to read it later.