What we need in order to install python?
First of all this beginners python tutorial will be done in python 3. Even though 2.7 is still quite popular we will be basing our tutorials on python 3.
First we need to download python. You can do this in the following operating systems by visiting.
https://www.python.org/ and clicking on the Download link. See below :
Then click on the yellow python download button to the left. Which should have a version number in it. As of this tutorial it is version 3.6.0.
In windows simply just install the executable. In linux specifically debian you can open a terminal window and type.
sudo apt-get install python3 pip3
We are installing pip as well as it helps in installing new packages in linux for python later on.
If you are working on a windows machine you can press the CMD(Windows) + R key to open a run box. Type in cmd and hit enter.
If you are in linux simply open a terminal window.
Lets run the python command line interpreter
If you have done everything correctly up until this point you should be able to run python3 or python on the command line and hit enter. To enter into the python command line interpreter.
You should now see a window similar to this below:
Lets run our first piece of code
From here we can easily execute code via the command line interpreter. Try the following:
By typing print(‘hello’) and hitting enter.
To do something a little more interesting you can try the following:
With a for construct we can easily print out a number sequence over and over again.
Now that we have you setup and you can do some basic python code. Lets move on to some slightly more fun python programming examples.