Welcome to the World of Input and Output!

Hi there! Have you ever wondered how a computer knows what you want it to do, or how it "talks" back to you? In this chapter, we are looking at Input and Output (often called I/O). This is the foundation of any computer program because, without it, a program would just be running in a lonely box with no way to interact with the world! Don't worry if you're new to this—we'll break it down step-by-step.

Think of a computer program like a vending machine. You give it an input (your money and your choice of snack), it does some processing (counting the change and moving the snack), and then it gives you an output (the chocolate bar and your change!).

1. Obtaining User Input

In the AQA 8525 curriculum, Input refers specifically to obtaining data from the keyboard. When we write a program, we need a way to stop the program and wait for the user to type something in.

What is a Prompt?

Imagine someone walks up to you and just stares at you without saying anything. You wouldn't know what to do! Computers are the same. A prompt is a message displayed on the screen that tells the user what they need to type. For example: "Please enter your age."

How it looks in code

In AQA Pseudo-code, we use the keyword USERINPUT. Usually, we store what the user types into a variable so the computer can remember it later.

Example:
OUTPUT 'What is your name?'
name ← USERINPUT

Quick Review:
1. The program outputs a question.
2. The program waits for the user to type.
3. The program assigns that value to a variable using the arrow (←).

Did you know?
When a computer is waiting for you to type, it is actually "idling." It might look like it’s working hard, but it's really just checking thousands of times a second to see if you've pressed the 'Enter' key yet!

Common Mistake to Avoid:

Forgetting the Prompt: If you use USERINPUT without an OUTPUT message first, the user will just see a blinking cursor on a blank screen. They won't know if they should type their name, their favorite color, or their password!

Key Takeaway: Input is how we get data into the program from the keyboard. Always use a clear prompt so the user knows what to do.

2. Displaying Output

Output is how the computer sends data and information back to the user. In this section, we focus on sending that information to the computer display (the screen).

Data vs. Information

Sometimes we output raw data (like the number 42), and sometimes we output information (like "Your score is 42"). To make a program "user-friendly," we usually combine text and variables together.

How it looks in code

In AQA Pseudo-code, we use the keyword OUTPUT. Anything inside single quotes ' ' is printed exactly as it is. Anything without quotes is treated as a variable.

Example:
score ← 10
OUTPUT 'Your total score is: '
OUTPUT score

Memory Aid: The "In-Out" Rule
Input = Information goes In to the program.
Output = Information comes Out of the program.

Step-by-Step: Printing a Greeting
1. The computer looks for the OUTPUT command.
2. It checks if there are quotes. If there are, it prints the text inside.
3. If there are no quotes, it looks in its memory for a variable with that name and prints the value stored inside.

Common Mistake to Avoid:

The Quote Trap: If you want to print the value of a variable called name, but you write OUTPUT 'name', the computer will literally print the word "name" instead of the person's actual name! Remember: Quotes for text, no quotes for variables.

Key Takeaway: Output is how the program "talks" to the user via the screen. Using a mix of text and variables makes the information much easier to understand.

3. Putting it All Together

Programs follow a pattern: Input → Process → Output.

Let’s look at a simple program that calculates how many days old you are (roughly!):

OUTPUT 'How old are you in years?' (Prompt)
years ← USERINPUT (Input)
days ← years * 365 (Processing)
OUTPUT 'You are at least this many days old:' (Output Text)
OUTPUT days (Output Variable)

Don't worry if this seems a bit long at first. Every program, from a simple calculator to a massive video game, uses these same basic building blocks to interact with the person using it.

Quick Review Box:
- USERINPUT: Gets data from the keyboard.
- OUTPUT: Shows data/information on the screen.
- Variable: A "container" used to store the input so we can use it later.
- Prompt: A message that tells the user what to type.

Final Key Takeaway: Programming is all about communication. Input lets the user talk to the computer, and Output lets the computer talk back to the user. Master these two, and you're well on your way to becoming a programmer!