1.1. What is a computer program?
Table of Contents
Understanding Computer Programs
A computer program is a set of precise instructions that a computer can follow to do something.
You can think of it like:
- A recipe the computer follows step by step.
- A to-do list for the computer, written in a language it understands.
- A set of rules that tells the computer how to react to different situations.
Programs can be tiny (a few lines) or huge (millions of lines), but they all have the same basic purpose: to tell the computer exactly what to do.
Programs vs. Apps vs. Scripts
You might hear different words:
- Program – a general term for any set of instructions a computer follows.
- Application (app) – usually a larger, user-facing program (like a web browser, game, or text editor).
- Script – often a smaller program that automates tasks or glues other programs together.
All of these are, at their core, computer programs.
What Does a Program Actually Do?
Most computer programs do some version of the same basic things:
- Receive input
- From the keyboard, mouse, files, the internet, sensors, etc.
- Example: A login form receives your username and password.
- Process data
- Apply rules, calculations, or decisions to the input.
- Example: Check if the password is correct.
- Store or retrieve data
- Save information for later, or load previously saved data.
- Example: Load your saved game, save a document, update a database.
- Produce output
- Show text, images, sound, or send data elsewhere.
- Example: Show “Login successful”, display a web page, play a song.
You can picture it like a simple flow:
$$\text{Input} \rightarrow \text{Processing} \rightarrow \text{Output}$$
Many real programs repeat this cycle over and over.
Programs Are Written in Programming Languages
Computers only understand very simple, low-level instructions (often called machine code). These are hard for humans to read and write, so we use programming languages instead.
A programming language is:
- A formal way of writing instructions for a computer.
- Designed to be readable by humans, but also strict and unambiguous.
Examples: Python, JavaScript, C, Java, etc.
A computer program is the result of writing instructions in one of these languages.
You’ll learn the details of Python itself later; for now, just keep in mind:
- A Python file (like
hello.py) is a program written in the Python language.
How Programs Run
When you write a program, it doesn’t do anything until it is run (or executed). Running a program means:
- The computer reads your instructions, one by one.
- It follows each instruction in order (unless your code tells it to jump, repeat, or choose between paths).
Conceptually:
- You write the program.
- The computer reads and executes it.
- You see the result (output, changed files, etc.).
Behind the scenes, there may be an interpreter (like Python) or a compiler translating your code into something the computer can work with, but the big picture is: your instructions get turned into actions.
Simple Examples of Programs
Here are some different kinds of computer programs you might recognize:
- Calculator app
- Input: numbers and operations (like
2 + 3) - Processing: does the math
- Output:
5 - Music player
- Input: user clicks “play”, chooses a song
- Processing: decodes audio data
- Output: sound through speakers
- Chat application
- Input: text you type
- Processing: sends text over the internet, receives messages from others
- Output: displays messages on the screen
- Small script to rename files
- Input: a folder of files
- Processing: changes names according to rules
- Output: updated file names on your computer
Even though these look very different, they are all computer programs: they receive input, process it, and produce output based on rules written by a programmer.
Programs Follow Rules Exactly
Computers do not “guess” what you meant. A key property of computer programs is that they are:
- Precise – every step must be clearly defined.
- Literal – the computer does exactly what the instructions say, not what you intended.
If instructions are:
- Incomplete – the computer doesn’t know what to do.
- Contradictory – the computer can’t follow them consistently.
- Ambiguous – the computer can’t choose a meaning.
…then the program will fail, crash, or behave unexpectedly.
This is why programming requires careful thinking about the steps and rules you give to the computer.
Where Do Programs Live?
Programs can exist in several forms:
- As files on your computer (like
game.exe,script.py,app.dmg). - As code on a server that runs websites and online services.
- As apps on your phone, tablets, or smart devices.
When you double-click an icon, tap an app, or visit a web page that runs code, you are causing a computer program to run somewhere (on your device, on a remote server, or both).
Why Understanding Programs Matters
Before you start writing code, it helps to be clear about what a program is:
- It’s not “magic” – it’s a sequence of steps.
- It doesn’t think for itself – it follows your instructions.
- If you can describe a task as a clear series of steps, you are already thinking like a programmer.
In the rest of this course, you’ll learn how to use Python to write your own computer programs: small, precise sets of instructions that tell a computer exactly what to do.
Views: 0
Where to Move
Move chapter:
- ☰ 1. Chapter 1: What Is Programming?
- ☰ 1.1. What is a computer program?
- ☰ 1.2. What is Python?
- ☰ 1.3. Where is Python used?
- ☰ 1.4. How programming helps solve problems
- ☰ 1.5. Your first Python program
-
- ☰ 2. Chapter 2: Setting Up Python
- ☰ 2.1. Installing Python (Windows / macOS / Linux)
- ☰ 2.2. Using Python in the terminal
- ☰ 2.3. Using an IDE (IDLE / VS Code)
- ☰ 2.4. Running Python scripts
- ☰ 2.5. Python interactive mode
-
- ☰ 3. Chapter 3: Variables and Data Types
- ☰ 3.1. What is a variable?
- ☰ 3.2. Creating variables
- ☰ 3.3. Numbers
- ☰ 3.4. Test
- ☰ 3.5. Boolean values
- ☰ 3.6. Type checking
-
- ☰ 4. Chapter 4: Basic Operations
- ☰ 4.1. Arithmetic operations
- ☰ 4.2. Working with numbers
- ☰ 4.3. String operations
- ☰ 4.4. Combining text and variables
- ☰ 4.5. Comments in Python
-
- ☰ 5. Chapter 5: User Input and Output
- ☰ 5.1. Getting input from the user
- ☰ 5.2. Converting input to numbers
- ☰ 5.3. Formatting output
- ☰ 5.4. Writing interactive programs
-
- ☰ 6. Chapter 6: Conditions
- ☰ 6.1. Comparison operators
- ☰ 6.2. Logical operators
- ☰ 6.3. if, elif, else
- ☰ 6.4. Nested conditions
- ☰ 6.5. Common beginner mistakes
-
- ☰ 7. Chapter 7: Loops
- ☰ 7.1. Why loops are useful
- ☰ 7.2. for loops
- ☰ 7.3. while loops
- ☰ 7.4. Loop counters
- ☰ 7.5. break and continue
- ☰ 7.6. Loop exercises
-
- ☰ 8. Chapter 8: Data Collections
- ☰ 8.1. Lists
- ☰ 8.2. Tuples
- ☰ 8.3. Dictionaries
- ☰ 8.4. Sets (basics)
- ☰ 8.5. Choosing the right data structure
-
- ☰ 9. Chapter 9: Functions
- ☰ 9.1. Why functions matter
- ☰ 9.2. Defining functions
- ☰ 9.3. Parameters and arguments
- ☰ 9.4. Return values
- ☰ 9.5. Scope (local vs global)
- ☰ 9.6. Reusing code
-
- ☰ 10. Chapter 10: Working with Files
- ☰ 10.1. What is a file?
- ☰ 10.2. Reading text files
- ☰ 10.3. Writing and appending files
- ☰ 10.4. File paths
- ☰ 10.5. Simple file-based programs
-
- ☰ 11. Chapter 11: Errors and Debugging
- ☰ 11.1. Types of errors
- ☰ 11.2. Reading error messages
- ☰ 11.3. Common beginner errors
- ☰ 11.4. try and except
- ☰ 11.5. Debugging strategies
-
- ☰ 12. Chapter 12: Using Python Libraries
- ☰ 12.1. What is a library?
- ☰ 12.2. Importing modules
- ☰ 12.3. Standard libraries
- ☰ 12.3.1. math
- ☰ 12.3.2. random
- ☰ 12.3.3. datetime
-
- ☰ 12.4. Installing external libraries with pip
-
- ☰ 13. Chapter 13: Object-Oriented Programming
- ☰ 13.1. What is object-oriented programming?
- ☰ 13.2. Classes and objects
- ☰ 13.3. The `__init__` method
- ☰ 13.4. Attributes and methods
- ☰ 13.5. Encapsulation
- ☰ 13.6. Inheritance (basics)
- ☰ 13.7. Simple OOP examples
-
- ☰ 14. Chapter 14: Automation with Python
- ☰ 14.1. What is automation?
- ☰ 14.2. Automating simple tasks
- ☰ 14.3. Working with files and folders
- ☰ 14.4. Automating text processing
- ☰ 14.5. Scheduling scripts
- ☰ 14.6. Practical automation examples
-
- ☰ 15. Chapter 15: Web Development with Python
- ☰ 15.1. How the web works (basic overview)
- ☰ 15.2. Introduction to Flask
- ☰ 15.3. Creating a simple web server
- ☰ 15.4. Routing and templates
- ☰ 15.5. Handling user input (forms)
- ☰ 15.6. Very basic APIs
-
- ☰ 16. Chapter 16: Data Science with Python
- ☰ 16.1. What is data science?
- ☰ 16.2. Working with data
- ☰ 16.3. Introduction to NumPy
- ☰ 16.4. Introduction to pandas
- ☰ 16.5. Data visualization with matplotlib
- ☰ 16.6. Simple data analysis examples
-
- ☰ 17. Chapter 17: Mini Projects
- ☰ 17.1. Number guessing game
- ☰ 17.2. Simple calculator
- ☰ 17.3. To-do list
- ☰ 17.4. Password generator
- ☰ 17.5. Quiz application
- ☰ 17.6. Small web or data project
-
- ☰ 18. Chapter 18: Next Steps
- ☰ 18.1. How to practice Python
- ☰ 18.2. Writing clean and readable code
- ☰ 18.3. Choosing a specialization
- ☰ 18.3.1. Web development
- ☰ 18.3.2. Data science
- ☰ 18.3.3. Automation
- ☰ 18.3.4. Software development
-
- ☰ 18.4. Learning resources and communities
-
- ☰ 19. Appendix
- ☰ 19.1. Python syntax cheat sheet
- ☰ 19.2. Common errors and solutions
- ☰ 19.3. Glossary of terms
-
Comments
Please login to add a comment.
Don't have an account? Register now!