Input/Output - Program Conversation
4 / 15

How Do Programs Talk With Us?

"We present information to the outside world by printing to the console, and we make our programs come alive by listening to user input."

The Two-Way Conversation

Apprentice (User)
→
input() — Listens (User sends text into a variable)
print() — Speaks (Program displays result on screen)
←
Python Program

Interactive Console & Memory Inspector

Console Output

Click "Run Program & Inspect Memory" to execute!

Live Variable Memory Inspector

name (str)
"Lyra"
age (int)
21
PITFALL WATCH The Critical Pitfall: Catching input() Inside a Variable + Explore
Common Mistake: Calling input() without assigning it to a variable is like asking someone their name and immediately forgetting it!
# [AVOID]  — The user's answer is never stored and vanishes immediately!
input("Enter your name: ")
print(name)  # NameError: name 'name' is not defined

# [GOOD]  — Catch the user's response inside a variable box!
name = input("Enter your name: ")
print("Hello, " + name)
TYPE RULE Remember: input() Always Returns a String! + Explore
"Even if a user types digits like 25 into input(), Python receives it as the text string '25'. To do math with it, wrap it in int()."
# 1. input() always gives you a string (text)
raw_age = input("Enter your age: ")   # User types 25 → raw_age is "25" (str)

# 2. Cast to int so you can do arithmetic
age = int(raw_age)                    # age is now 25 (int)
next_year = age + 1                   # 26 (int)

# 3. Cast back to str if gluing into a sentence with +
print("Next year you will be " + str(next_year))
Sakura Blossoms
Card 4 Takeaway (Sakura Blossoms Unlocked!): You have completed the entire Foundations Realm (Cards 0–4)! You now know how to sequence instructions, store data in variables, respect data types, and converse with users via input() and print().
Use print() to speak and input() to listen. Always store input() inside a variable, and wrap it in int() when you need math.
Wizard Guide