Login
Password

Forgot your password?

Learn How to Program a Computer - Setting Up The Python Development Environment

By Edited Oct 6, 2016 0 0

Writing computer programs requires a development environment. This is usually a computer application that installs with a number of specialized supporting files. The environment readies the computer to execute a custom written program. There are many different development environments. Many beginners find that the Python language is easy to use and to learn. It is also free to use, is supported by most modern computers and is able to handle difficult tasks as the new programmer develops their skill. Even children can be taught to program a computer with the Python programming language.

The Python development environment consists of an interpreter, documentation and some support tools. The interpreter takes a program that is written in an English-like language and translates it into a computer machine program consisting of numerical instructions and data. For example, the interpreter takes this small Python program:

Balance = Balance - Order_amount
if Balance >= 0 :
print("Order is being processed")

and converts it into this machine program:

F328 F588 0023 3322 CC01 1000 1000 231B AA90 4443 5565 FFFA 778C BB00 0000 0065 0066 0067


Obviously, programmers can understand the Python program far easier than the machine program. Perhaps the programmer wants the code to process if the balance is greater than 10, not 0. In Python, you change the line to this:

if Balance >= 10 :


In the machine program, the 4th last set of numbers would change from 0000 to 1010.

Python is a free language. All of the necessary tools, documentation, interpreter and even the program code of the language itself are available to anyone who wants it. You are fully able to use Python as much as you want. You can write programs for sale and not pay royalties to anyone. It is a great language to use because it's free, but it's also very powerful.

To get Python, you need to go to www.python.org/download/ to get the download package. The current versions of Python are 2.7 and 3.1.2. While each is excellent, 3.1.2 is newer and fixes some historical Python problems. Unless you have a compelling reason to use 2.7, you should get the 3.1.2 version. (If there is a higher number at the download site, teh beginner should choose that as their Python version.) Assuming that you have a Windows computer, you would select the "Python 3.1.2 Windows x86 MSI Installer (Windows Binary -- does not include source)" download option. This is the fastest download for most people. Later on, when you determine that your needs change, you can get the language source code or the alternate Windows 64 bit version as necessary. Those people with Mac, Linux or other computers will need to select the download that corresponds to their hardware. People using Linux, and some other similar systems, should check to see if Python is already available to them.

Run the download program and it will install Python on your computer for you. Select the default option which will install Python in a folder called Python31. At the "Customize Python" box, choose "next" to select the defaults. After a few moments, Python will be installed and validated. When the completion box is displayed, click finish to exit the installer. Although it will look as though nothing has happened, the Python development environment will now be available for you to use. Click on the Windows start button. It will show that new programs have been installed under "All programs". Select "All programs" and at the end of the menus, you should see "Python 3.1" as a new menu option. In that menu, you should see "IDLE (Python GUI)" as a selection. This is the GUI, or "Graphical User Interface", for the Python language. When you run it, you will see an application running called "Python Shell". In the shell, type in the following and press enter:

print("Hello world")


Assuming that all is well, it should look substantially like this:

Hello world output

Congratulations! Python is installed and ready to go on your computer. You can now explore the Python language and start to use it to build your own custom programs. It can do a lot for you but you need to start small. In the next articles in the "Learn How to Program a Computer", you will see how to write Python programs that actually do things. They will be very simple at first in order to fully identify the basics of the language. Later articles will show more complex programs. In the end, you will see how to write a custom program in Python that will use a database to store data records. This program will be functional and will show the basics of database control and error handling. It will illustrate the basic concepts that are in use in the field of computer technology today.

The Python shell is quite capable of doing more than printing "Hello world". This is the Python editor so it is ready to execute Python commands. Try out the following:

5 + 10
"this" + "that"
10/5
10/3
10 - "that"

The last one will trigger an error. You can't hurt anything, however. The interpreter will simply display an error message and then ready itself for the next command:

10 - 10

Just shut down the Python shell when you are finished.

Writing Python programs directly into the shell is very tedious. It is easier to create a text file that contains the Python code that you want to execute. In order to write text file programs, you need to get a text editor. While Windows does come with Notepad, this editor is extremely limited in functionality. There are instructional articles available that describe the processes needed to install and use an alternate editor. With an editor, you will be able to develop source code programs more easily.

In order to write more substantial programs, you should understand the concept of Windows folders. Each of your programs should be in their own folder if they are going to be developed into applications. While you are learning, you can write all of your introductory programs in a single folder. The articles in this series assume that you will put all of your programs in a folder called "My Python" while you are learning. While this is optional, those programmers using a different folder name will have to convert the example file references themselves. This shouldn't be difficult, however, and can even be learned by children. With your new Python environment installed, you are ready to have fun with data.

Advertisement
Advertisement

Comments

Add a new comment - No HTML
You must be logged in and verified to post a comment. Please log in or sign up to comment.

Explore InfoBarrel

Auto Business & Money Entertainment Environment Health History Home & Garden InfoBarrel University Lifestyle Sports Technology Travel & Places
© Copyright 2008 - 2016 by Hinzie Media Inc. Terms of Service Privacy Policy XML Sitemap

Follow IB Technology