The learning goal of this step is for students to understand how to use input() to receive data from the user and how to display results with print(). They will realize that input() always returns a string, and they will practice combining input and output to create simple interactive programs.
In the past lessons, our programs were one-way we wrote the code, and the computer printed results. But the exciting part is interaction that programs can talk with people. Just like a game asks for your character’s name. In Python, we use input() for input and print() for output.
Example A: Getting a name
name = input("Enter your name: ")
print("Hello,", name)
When you run this, the program pauses for your input. Whatever you type is stored in the variable name, then printed with print().
Example B: Printing multiple items
food = input("What is your favorite food? ")
print("Your favorite food is", food)
In print, if you separate items with commas, Python automatically adds spaces between them.
Example C: Concatenation vs Comma
animal = input("What animal do you like? ")
print("I like " + animal) # Concatenation
print("I like", animal) # comma
Both ways work. Concatenation requires you to add the space manually, while the comma way adds spaces automatically.
But what happens if I type a number, like 10? Will the program treat it as a number or as text?
Example D:
a = input(" Please enter a number: ")
b = input("Please enter another number: ")
print(a + b)
Now your programs can talk with you. But here’s a problem: if you enter numbers, they’re still treated as strings, which makes calculation tricky. Next, we’ll learn how to turn strings into numbers—type conversion.