Elena' s AI Blog

Talking to the Machine: Interactive Programs

05 Jan 2026 / 2 minutes to read

Elena Daehnhardt


Lesson 3 of 10 30%


TL;DR: Use `input()` to pause the program and wait for the user to type something. You can save their answer in a variable.

Only Talking, Never Listening?

So far, our programs have been a bit bossy. They tell us things (“Hello!”, “Score is 100”), but they don’t listen to us. Imagine a friend who only talks about themselves and never asks “How are you?”. Annoying, right?

Let’s teach our computer manners.

The Listening Ear: input()

The command to make Python listen is input().

name = input("What is your name? ")
print("Hello", name)

What Happens Here?

  1. input("..."): The computer prints the question and pauses. It waits. It blinks cursor at you.
  2. You type: “Elena” (and hit Enter).
  3. name =: The computer catches what you typed and puts it in the name box.
  4. print: It uses that name to say hello.

The Robot Waiter

Let’s build a Robot Waiter. It needs to ask what you want to eat.

print("--- ROBOT CAFE ---")
food = input("What would you like to eat? ")
drink = input("And to drink? ")

print("Coming right up!")
print("Here is your", food, "and", drink)

If you run this: Robot: What would you like to eat? You: Pizza Robot: And to drink? You: Slime Juice Robot: Coming right up! Here is your Pizza and Slime Juice

Important Rule: Inputs are Text

When you use input(), the computer treats everything as text (a “string”). Even numbers!

If you type 10 for an age, the computer keeps it as the word “10”, not the number 10. We will learn how to fix that later, but for now, remember: input returns text.

Try It Yourself

Make a “Silly Story” generator. Ask for:

  1. An animal
  2. A color
  3. A funny noise

Then print a sentence like: “The [color] [animal] shouted [noise]!”


This post is part of the Python Basics for Kids series, based on “Python for Kids from 8 to 88”.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.

Citation
Elena Daehnhardt. (2026) 'Talking to the Machine: Interactive Programs', daehnhardt.com, 05 January 2026. Available at: https://daehnhardt.com/courses/book0/03-talking-to-computer/
Course Library