Lesson 1: Introduction
What is a Computer Program?
A computer program is a set of instructions or code that tells a computer what to do. It is written in a programming language that the computer can understand and run. A computer program can perform a wide variety of tasks, from simple calculations to complex data analysis or game development. Programs can be created for a specific purpose, such as a word processor or web browser, or they can be designed to be flexible and adaptable, capable of performing a variety of tasks depending on the user's input. After a program is written, it can be compiled into a format that the computer can understand and run. We will give examples using Python.
Install Python
To install Python:
- Download the latest version of Python from https://www.python.org/downloads/
- An .exe installation file is saved to your downloads folder
- Double click the installation file
- Open a command prompt by pressing start and typing cmd.
- At the command prompt, type python and press Enter. If you see a version number and a ">>>" prompt, your install was successful
The first example is the “Hello World” program.
At the prompt, type print(“Hello World”) and press Enter.
The text “Hello World” is printed to the screen.
Next, we print using a program instead of using the interactive Python console.
- Press Ctrl+Z to exit the Python console.
- Create a folder on your desktop called python examples
- Open your favourite text editor and type the same command as used earlier: print(“Hello World”)
- Save the file as hello_world.py. This is now a python program as all python programs all end in ‘py’.
- Run the program we have just written. To do this, at the command prompt, type python followed by the full name of the program, for example: python hello world.py
Notepad++ is a free editor with functionality that is useful when writing code.