Setting Up Python - Python Programming for Beginners (2015)

Python Programming for Beginners (2015)

Chapter One: Setting Up Python

In this chapter, you will learn:

· How to download and install the Python interpreter

· How to use the Python Shell

Before you do any programming you need to get Python set up on your computer. In this book we will teach you how to program in Python 3, which is the latest version of the software. If you need to use Python 2 in the future then that is fine, both versions of Python are very similar. If you learn Python 3 then you should have no problem understanding Python 2.

In order to download and install the interpreter for Python you just visit . It will give you an option of the different versions at the top of the page. You just need to choose the latest Python 3 version, click on it and then download it.

If you need a different version of Python then you just need to scroll down the page and choose the version you want to use.

Once you've downloaded the version of Python you need then all you need to do is install it, then we will be ready to start coding.

Using the Python Shell

We are going to do all of our coding on the IDLE (Integrated DeveLopment Environment) program which comes with Python. IDLE is created to be a very simple IDE and it is something you may have seen before if you use Linux as it is bundled with many Linux programs. IDLE was fully coded in Linux and is created to be very easy for beginners to use.

You launch IDLE the same way that you would launch any other program on your computer. When you start up Python it will present you with the Python Shell, which runs Python in interactive mode. This allows you input a command which it will instantly run before waiting for the next command.

You can start by inputting a few simple commands like the ones below:

>>> 2 + 5

>>> 1<5

>>> print ('Hello World')

Type them into the Python Shell and watch as it will instantly return the result of your command. The first command will run the sum 2 plus 5, which will return the answer 7. The second command will run the equation “is 1 less than 5” which will return the answer True. The third command will tell the shell to display the words “Hello World” which it will instantly do.

The Python Shell is perfect for testing out new commands and seeing how Python works, but it will not save any of your coding. If you want to develop a program you need to write your code and save it in a .py file, which is called a Python script. To do this you just need to click on File > New File at the top menu which will bring up the editor we are going to use to develop our programs

Now we're all ready to start coding, in the next chapter we're going to create our first program!