Concepts / Variables: Storing and Naming Data

Variables: Storing and Naming Data

Input is the process of getting data from the outside world into a program. Common sources include keyboards, files, sensors, and networks.

  • Programming

A Program Needs a Connection

A program becomes useful when it can interact with something outside itself. It receives information, does something with that information, and sends a result somewhere. Input and output are the bridges between a program and the real world: input brings data in, while output sends results out.

What do you think happens?

A program receives information, transforms it, and displays a result. Which part describes the information entering the program?

  • Input

  • Processing

  • Output

Reveal answer
Answer:

Input

Input is the process of getting data from the outside world into a program. Processing transforms the data, and output displays or stores the result.

The Three-Part Cycle

All programs follow the Input-Process-Output cycle. First, the program receives data. Next, it processes that data by performing calculations or transformations. Finally, it produces results. The cycle may happen once, repeat when a program waits for more input, or repeat continuously many times per second.

InputData enters the programProcessData is transformedOutputResults leave the programreceived datatransformed results
How does data move from an outside source into a program, get processed, and become displayed or stored output?
Key point

Without input, a program has no information to work with. Without output, the results of processing remain invisible or unusable.

Tracing a Simple Request

Worked example

A User Enters Information

Trace what happens when a user types information into an initial program and the program displays a result on the screen.

  1. 1
    Input

    The user types information using a keyboard. That keyboard data enters the program.

  2. 2
    Process

    The program uses the received information to perform a calculation or transformation.

  3. 3
    Output

    The program displays the result as text or numbers on the screen.

Result

The request follows the complete Input-Process-Output cycle: keyboard input enters, the program processes it, and screen output displays the result.

This example uses keyboard input and screen output because those are the main forms used in initial programs. The same pattern applies when the source or destination changes: the program still receives data, processes it, and sends results somewhere.

Sources and Destinations

Definition

Input is the process of getting data from the outside world into a program. Common input sources include keyboards, files, sensors, and networks.

Definition

Output is the process of displaying or storing program results. Common output destinations include screens, files, speakers, and devices.

KeyboardInput sourceProgramReceives and processes dataScreenOutput destinationFileInput sourceFileOutput destinationSensorInput sourceSpeakersOutput destinationNetworkInput sourceDeviceOutput destinationinputinputinputinputoutputoutputoutputoutput
What are the different places data can come from, and where can program results go?

Repeating the Cycle

Input, processing, and output do not have to happen only once. A program can receive input, process it, produce output, and then wait for more input. Other programs repeat the cycle continuously, receiving data, processing it, and displaying results many times per second.

Worked example

A Sensor-Based Program

Describe the cycle for a scientific instrument that gathers sensor data and saves results for later analysis.

  1. 1
    Receive

    The instrument receives data from sensors.

  2. 2
    Transform

    The program processes the sensor data.

  3. 3
    Send

    The program writes the results to a file for analysis.

  4. 4
    Repeat

    The instrument can continue receiving, processing, and saving new sensor data.

Result

The same Input-Process-Output cycle can support a continuing stream of data, not just one interaction.

Check Your Understanding

MEDIUM

For each situation, identify the input source, the processing step, and the output destination: a user enters information with a keyboard and the program shows a result on a screen; a sensor provides readings and the program saves processed results to a file; a web application receives information from a browser and sends a web page.

Hints
  • Input identifies where data enters the program.
  • Processing describes what the program does with the received data.
  • Output identifies where the result is displayed or stored.
  • Common mistake

    Treating input and processing as the same step

    What it looks like

    Calling a calculation performed by the program input

    Why it fails

    Input is data entering the program. A calculation or transformation happens during processing.

    Do this instead

    First identify how the program receives data, then identify what it does with that data.

  • Common mistake

    Assuming output must appear on a screen

    What it looks like

    Ignoring a file that stores the program's results

    Why it fails

    Output can be displayed or stored, and common destinations include files, speakers, and devices as well as screens.

    Do this instead

    Look for the place where the program's results go, whether that is a screen, file, speaker, or device.

  • Common mistake

    Describing only the first interaction

    What it looks like

    Assuming a program finishes after one input and one output

    Why it fails

    The Input-Process-Output cycle can repeat when a program waits for more input or continuously handles new data.

    Do this instead

    Ask whether the program repeats the cycle.

Key Takeaways

  1. 1
    Input gets data from the outside world into a program.
  2. 2
    Processing transforms or uses the received data.
  3. 3
    Output displays or stores the program's results.
  4. 4
    Keyboards, files, sensors, and networks can provide input.
  5. 5
    Screens, files, speakers, and devices can receive output.
  6. 6
    Together, input, processing, and output form a cycle that can repeat.

At a glance

  • Input is data entering a program from an outside source.
  • Output is a program's result being displayed or stored somewhere.
  • Programs connect input and output through a processing step.
  • The Input-Process-Output cycle can happen once or repeat continuously.
  • The program's purpose determines which input sources and output destinations are appropriate.

Related concepts

More concepts starting with V