No history yet

Speaking to Computers

Giving the Computer Instructions

At its heart, programming is just a way of giving instructions to a computer. Think of a computer not as a genius, but as an incredibly obedient and fast assistant that takes everything you say literally. It can perform millions of calculations in the blink of an eye, but it won't do anything until you tell it exactly what to do, step by step.

Programming

noun

The process of writing instructions for a computer to execute. These instructions, written in a specific language, tell the computer what to do and how to do it.

To give these instructions, we use a programming language. There are many different kinds, but they generally fall into two categories: low-level and high-level.

Low-level languages are very close to the computer's native tongue of 1s and 0s. They are difficult for humans to read but are extremely fast and efficient. Think of it like giving a robot precise instructions on which circuits to activate.

High-level languages, like Python, are designed to be read and written easily by people. They use words and structures similar to English, making them much more beginner-friendly. This human-readable code is then translated into the computer's language by a special program.

FeatureHigh-Level Language (e.g., Python)Low-Level Language (e.g., Assembly)
ReadabilityEasy for humans to read and write.Difficult for humans to read.
SpeedSlower, as it needs translation.Very fast and efficient.
Use CaseWeb development, data science, general apps.Device drivers, operating systems.

We're using Python because it's known for its clean and simple syntax. To bridge the gap between our Python code and the computer's hardware, we use something called an interpreter an interpreter's job is to read our high-level code line by line and execute it immediately. This makes it quick and easy to see the results of our work.

The Basic Workflow

No matter how complex a program is, it follows a simple, fundamental model: Input, Process, and Output (IPO).

  1. Input: The program receives some data. This could be text typed on a keyboard, a click of a mouse, or information from a file.
  2. Process: The program takes the input and performs some actions on it based on the instructions we've written.
  3. Output: The program produces a result. This could be text displayed on the screen, a new file, or a change in an image.

For example, a calculator app takes your number clicks (input), performs the addition or subtraction you requested (process), and displays the answer on its screen (output). We're about to write a program that does something similar, but much simpler.

Your First Program

Let's write our first piece of code. All programming is done in a text editor, often a specialised one called a that adds helpful features like colour-coding your text to make it more readable. For now, we'll just focus on the code itself.

The most basic task in programming is displaying information. In Python, we do this with the print() function. A function is a named block of code that performs a specific task. The print() function's task is to take whatever you put inside its parentheses and display it on the screen.

Lesson image

Type the following line of code exactly as it appears:

print("Hello, World!")

Let's break this down:

  • print is the name of the function.
  • () The parentheses are where we provide the input for the function.
  • "Hello, World!" is the data we are giving to the function. This specific type of data, a sequence of characters, is called a string. The quotation marks are important, they tell Python that this is text to be displayed literally.

When you run this code, the Python interpreter will read it, see the print command, and display the text Hello, World! on your screen. Congratulations, you've just written and executed your first computer program.

Now, let's test your understanding of these fundamental ideas.

Quiz Questions 1/5

What is the primary purpose of a programming language?

Quiz Questions 2/5

Which statement best describes a high-level language like Python?

This simple print() function is the first step. From here, we'll learn how to handle different types of data, make decisions, and repeat actions to build much more powerful programs.