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.
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?
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.
Without input, a program has no information to work with. Without output, the results of processing remain invisible or unusable.
Tracing a Simple Request
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.
Input: The user types information using a keyboard. That keyboard data enters the program.
Process: The program uses the received information to perform a calculation or transformation.
Output: The program displays the result as text or numbers on the screen.
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
Input is the process of getting data from the outside world into a program. Common input sources include keyboards, files, sensors, and networks.
Output is the process of displaying or storing program results. Common output destinations include screens, files, speakers, and devices.
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.
A Sensor-Based Program
Describe the cycle for a scientific instrument that gathers sensor data and saves results for later analysis.
Receive: The instrument receives data from sensors.
Transform: The program processes the sensor data.
Send: The program writes the results to a file for analysis.
Repeat: The instrument can continue receiving, processing, and saving new sensor data.
The same Input-Process-Output cycle can support a continuing stream of data, not just one interaction.
Check Your Understanding
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.
Treating input and processing as the same step
Input is data entering the program. A calculation or transformation happens during processing.
Fix:
First identify how the program receives data, then identify what it does with that data.Assuming output must appear on a screen
Output can be displayed or stored, and common destinations include files, speakers, and devices as well as screens.
Fix:
Look for the place where the program's results go, whether that is a screen, file, speaker, or device.Describing only the first interaction
The Input-Process-Output cycle can repeat when a program waits for more input or continuously handles new data.
Fix:
Ask whether the program repeats the cycle.
Key Takeaways
- Input gets data from the outside world into a program.
- Processing transforms or uses the received data.
- Output displays or stores the program's results.
- Keyboards, files, sensors, and networks can provide input.
- Screens, files, speakers, and devices can receive output.
- Together, input, processing, and output form a cycle that can repeat.
Key Takeaways
- 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.