Input/Output CS Thinking Example 1

Follow the full solution, then compare it with the other examples linked below.

Example 1

easy
Identify the inputs and outputs in this program: name = INPUT('What is your name?'). age = INPUT('How old are you?'). OUTPUT 'Hello ' + name + ', you are ' + age + '.'

Solution

  1. 1
    Step 1: Inputs are data the program receives from the user. Here there are two inputs: name and age.
  2. 2
    Step 2: The OUTPUT statement displays a message to the user โ€” this is the program's output.
  3. 3
    Step 3: The program takes two inputs (name and age) and produces one output (a greeting message).

Answer

Inputs: name and age (from user). Output: a personalised greeting message.
Input is data entering a program (keyboard, file, sensor). Output is data leaving a program (screen, file, speaker). Every useful program has at least one input or output.

About Input/Output

The mechanisms by which a program receives data from the outside world (input) and sends results back (output). Input can come from keyboards, files, sensors, or network connections; output can go to screens, files, printers, or other devices.

Learn more about Input/Output โ†’

More Input/Output Examples