Introduction
The history of programming languages is not gospel to anyone in the field. The history begins with a woman by the name of Ada Lovelace and her partner Charles Babbage while working on the Analytical Engine. Lovelace developed an algorithm to be used on the Analytical Engine to compute the Bernoulli numbers, a sequence of rational numbers that occur frequently in analysis. Since then there has been a huge growth in the field of programming.
In 1991 at Centrum Wiskunde & Informatica (CWI), Guido Van Rossum, a Dutch programmer developed a programming language that would be easy to read, easy to debug, and also easy to extend which we now know as The Python programming language.
Python programming language is a high-level programming language that is easy to code with its ‘English-like’ code statements thus making it the most sought-after language in recent times.
Setting up the python environment
Python is a cross-platform programming language, what this means is that any program written in python can run in any operating system.
To develop a python program one will need to install the following:
Python
i. This can be installed from python’s website
https://www.python.org/downloads/
ii. Choose the operating system you are using to develop the programs. E.g Windows
iii. Download the version of python. It is always recommended to download the latest and most stable version.
iv. Install it to your computer
A text editor
This is the environment within which the programmer writes their code.
There are many text editors e.g Visual basic code, sublime text, vim e.t.c
Writing our first program in python
Now that the environment is ready we can code and execute our first python program.
We are going to write a program that outputs the following text message “Hello World”
i. Open the text editor and open a new file.
Save the file with the .py extension. e.g. hello.py. The .py extension is used to distinguish the python files from other files.
ii. Write the following
print(“Hello world!”)
iii. If you are using the visual studio code editor. You will just click on the play button contained in the toolbar on the upper side of the text editor to run the program
Alternatively, one can run the program from the terminal.
- Open the terminal and using the cd function navigate to the folder containing the hello.py file.
- Once there use the following command to run the program python(version of python you are using) filename e.g.python3 hello.py
- Click Enter
- The following should be displayed Hello world!
Top comments (0)