Install and run Python on your Operating System

Install and run Python on your Operating System


Run and install Python on Windows

The latest version of Python can be downloaded from the following link

https://www.python.org/downloads/

The software will be downloaded just like other software on windows.

When you click on any of the version button the following downloading dialog box will be opened:

downloading

When the download is complete open it, python setup will appear:

python-setup-will-appear

Click on the Install Now button. And the software will be installed by following the installation steps. The python DOS prompt will also be installed. Now open the DOS prompt. The DOS prompt looks like the following:

Now open the DOS prompt

If you want to display a message, suppose you want to display a message “I love my Country” then write the following lines of code to the DOS prompt:

print (“I love my Country”)

It will look like the following in the DOS prompt:

it-will-look-like-the-following-in-the-dos-prompt

When you press the enter key the message will be displayed on the screen:

enter-key

The python IDLE is also installed when the python is installed. To open the IDLE in windows, click on the start button and type IDLE, then press the enter key. The IDE will appear as follows:

the-ide-will-appear-as-follows

Type the example of print statement mentioned above and press the enter key the result will be displayed:

print (“I love my Country”)

i-love-my-country

To save the file

Click on the file menu and select save file, the file will be saved with .py extension.

save-file

To open a new file click on the file menu and select new a new file will be opened or simple press ctrl + N.

Consider the following example in which we are adding two numbers and then displaying the sum of the two numbers:

x = 2

y = 3

sum = x + y

print (sum)

Copy and paste the above lines of to the IDLE and press enter key to see the results:

idle-and-press-enter

When you press the enter key the module will not run. To run this click on the run menu and select run module or simple press F5 key. The result will be displayed in another IDLE window:

f5-key

Your first program has been successfully run and its result has been displayed.

 

Run and install Python in Mac OS X

The latest version of Python can be downloaded from the following link:

https://www.python.org/downloads/

Select the version that you want to download for your Mac OS X. After the download is completed follow the steps and when python is installed successfully a message will appear that Python is installed successfully.

Before getting starting to python on Mac OS X you should also install a text editor such as Sublime text editor it can be downloaded from the following site for free:

https://www.sublimetext.com/2

When the sublime text editor is downloaded you can open the editor and before writing the first program open a new file from the file menu and selecting new file. The shortcut to open a new file in sublime text editor is Cmd + N. If you want to save the file click on the file menu and select save, the file will be saved with .py extension. The shortcut to save a file is Cmd + S.

If you want to display a message, suppose you want to display a message “I love my Country” then write the following lines of code to the sublime text editor:

print (“I love my Country”)

This will be your first program and the output of this will be “I love my Country”.

To run the program click on Tool and select build. The output will appear to the bottom of the sublime text editor. The shortcut to run a program is Cmd + B.

 

Install and run Python on Linux

The latest version of Python can be downloaded from the following link:

https://www.python.org/downloads/

Select the version that you want to download for Linux. After the download is completed follow the steps and when python is installed successfully a message will appear that Python is installed successfully.

Install the following to your system:

$ sudo apt-get install build-essential checkinstall

$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Run the following command on the directory in the terminal:

 $ tar -xvf Python-3.5.2.tgz

The purpose of running the above command on the directory is to extract the zipped file. You should also use the appropriate file name because the file name is different for different versions.

To run the python programming language on Linux Ubuntu, install sublime text editor. It can be downloaded from the following site for free:

https://www.sublimetext.com/2

When the sublime text editor is downloaded you can open the editor and before writing the first program open a new file from the file menu and selecting new file. The shortcut to open a new file in sublime text editor is Cmd + N. If you want to save the file click on the file menu and select save, the file will be saved with .py extension. The shortcut to save a file is Cmd + S.

If you want to display a message, suppose you want to display a message “I love my Country” then write the following lines of code to the sublime text editor:

print (“I love my Country”)

This will be your first program and the output of this will be “I love my Country”.

To run the program click on Tool and select build. The output will appear to the bottom of the sublime text editor. The shortcut to run a program is Cmd + B.