A computer program is a sequence of instructions with a purpose. You do not need to know programming vocabulary to understand its basic job.
Understanding the Concept
Imagine a recipe: it names ingredients, gives instructions, and produces a result. A program is similar, except its instructions must use precise rules that a computer can follow. A program can receive information, calculate something, make a decision, repeat an action, or save a result. Humans decide the goal and rules; the computer carries out the instructions exactly as written.
When and Why You Would Use This
A greeting program is a useful starting point. It receives a name from the person running it and then produces a message. The program does not know whether the name is correct or polite unless the programmer writes rules to check it.
Practical Example
visitor_name = input("What is your name? ")
print("Hello,", visitor_name)
Understanding the Example
input() displays a question and waits for keyboard input. When the user types a name and presses Enter, Python stores the reply as text. print() then displays the greeting. This is a real input/output interaction, even though it has no buttons or graphical window.
Example Output
What is your name? Hello, 24
Try It Yourself
Draw a three-part diagram on paper: input (name), processing (build greeting), output (message). Add a second input for a favorite color.
Common Beginner Mistakes
- Expecting the computer to infer your intentions. A program performs only the behavior you have specified.
- Assuming every program needs a graphical interface. Many valuable programs run in a terminal.
- Confusing a value supplied by the user with a fact already known by the program. Inputs need validation when accuracy matters.
Key Takeaways
- A program is an exact set of instructions designed to achieve a goal.
- Many programs collect input, process it, and return output.
- Text-based programs are a valid and useful place to begin.