seegongsik
Saved words
Programming

How do we exchange values?

Last time we put a value in a box. But how do we see that value, and how do we put in a new one? Let's look at the two directions we and a program exchange.

01

A conversation has two directions

Just as people talk,
we exchange
with a program too.
The computer
showing us something,
and us
putting something into the computer.
These two directions
are the communication of every program.

ComputerOutput: shows letters or pictures on the screen. The computer talking to us.
MeInput: we put in letters or numbers. Us talking to the computer.

Between the computer and us, two directions.

What the computer shows
is called output,
what we put in
is called input.
With just these two
you can have any conversation
with a program.

02

Output puts a value on the screen

First, output.
Showing a value the program has
on the screen.
Remember that box (variable)
we made last time?
Say "show the value in the name box,"
and that value
appears on the screen.
Press the button.

show(greeting)
the greeting box holds "Hello"
Nothing shown yet

Output a variable's value to the screen.

Thanks to output,
we can see with our eyes
the values inside a computer.
Calculation results,
stored information,
if we don't output them
we have no way to know.

03

Input takes a value and puts it in a box

The opposite direction is input.
When we put in letters or numbers,
that value goes into a variable.
"Take the name as input
and put it in the name box."
Like this.
Input always leads
to being held in a box.
Try putting one in.

name
Still empty
The value you type goes into the 'name' box

The value you input goes into a variable.

Thanks to input,
a program listens to us.
Even the same code
behaves differently
by the value you put in.
Like greeting you by name
once you put your name in.

04

Take turns and it becomes a conversation

Take turns with output and input
and a real conversation begins.
The computer asks (output),
we answer (input),
the computer answers back (output).
This give-and-take
is the basic skeleton
of every app we use.

Computer · OutputWhat is your name?
Me · InputMinjun
Computer · OutputHello, Minjun!
Ask (output) · answer (input) · answer (output)

Ask (output), answer (input), answer (output).

Chat apps,
games,
the search box,
are all really this.
The back-and-forth
of output and input.
There's just complex stuff
stacked on top.

05

A program that takes input and greets

Now combine the two
and make a small program.
Take a name and age as input (input),
use them to make a greeting
and put it on the screen (output).
Put in values
and press run.
The result is made
from what you input.

The result shows here when you run

Input → process → output.

Take a value with input,
make something with that value,
show it with output.
This flow is the basics of a program.
Next time we'll look into
whether these values are numbers or letters,
their kinds.

In one lineOutput is the computer showing a value on the screen, input is us putting in a value to be held in a variable. Taking turns with these two is how every app we use has a conversation with us.
Was this helpful? Support seegongsik
Programming