top of page
Writer's pictureThe Tech Platform

Python Programming Language



Python is a powerful general-purpose programming language. It is used in web development, data science, creating software prototypes, and so on. Fortunately for beginners, Python has simple easy-to-use syntax. This makes Python an excellent language to learn to program for beginners.


Python is a high-level, general-purpose and a very popular programming language. Python programming language (latest Python 3) is being used in web development, Machine Learning applications, along with all cutting edge technology in Software Industry. Python Programming Language is very well suited for Beginners, also for experienced programmers with other programming languages like C++ and Java.


History:

Python was conceived in the late 1980s by Guido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands as a successor to ABC programming language, which was inspired by SETL, capable of exception handling and interfacing with the Amoeba operating system. Its implementation began in December 1989. Van Rossum shouldered sole responsibility for the project, as the lead developer, until 12 July 2018, when he announced his "permanent vacation" from his responsibilities as Python's Benevolent Dictator For Life, a title the Python community bestowed upon him to reflect his long-term commitment as the project's chief decision-maker. He now shares his leadership as a member of a five-person steering council. In January 2019, active Python core developers elected Brett Cannon, Nick Coghlan, Barry Warsaw, Carol Willing and Van Rossum to a five-member "Steering Council" to lead the project. Guido van Rossum has since then withdrawn his nomination for the 2020 Steering council


Syntax:

Invoking the interpreter without passing a script file as a parameter brings up the following prompt −

$ python
Python 2.4.3 (#1, Nov 11 2010, 13:34:43)[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>>

Type the following text at the Python prompt and press the Enter −

>>> print "Hello, Python!"

If you are running new version of Python, then you would need to use print statement with parenthesis as in print ("Hello, Python!");. However in Python version 2.4.3, this produces the following result −

Hello, Python!

Installing Python

Python distribution is available for a wide variety of platforms. You need to download only the binary code applicable for your platform and install Python.


If the binary code for your platform is not available, you need a C compiler to compile the source code manually. Compiling the source code offers more flexibility in terms of choice of features that you require in your installation.


Here is a quick overview of installing Python on various platforms −


Unix and Linux Installation

Here are the simple steps to install Python on Unix/Linux machine.

  • Open a Web browser and go to https://www.python.org/downloads/.

  • Follow the link to download zipped source code available for Unix/Linux.

  • Download and extract files.

  • Editing the Modules/Setup file if you want to customize some options.

  • run ./configure script

  • make

  • make install

This installs Python at standard location /usr/local/bin and its libraries at /usr/local/lib/pythonXX where XX is the version of Python.


Windows Installation

Here are the steps to install Python on Windows machine.

  • Open a Web browser and go to https://www.python.org/downloads/.

  • Follow the link for the Windows installer python-XYZ.msi file where XYZ is the version you need to install.

  • To use this installer python-XYZ.msi, the Windows system must support Microsoft Installer 2.0. Save the installer file to your local machine and then run it to find out if your machine supports MSI.

  • Run the downloaded file. This brings up the Python install wizard, which is really easy to use. Just accept the default settings, wait until the install is finished, and you are done.


Macintosh Installation

Recent Macs come with Python installed, but it may be several years out of date. See http://www.python.org/download/mac/ for instructions on getting the current version along with extra tools to support development on the Mac. For older Mac OS's before Mac OS X 10.3 (released in 2003), MacPython is available.


Jack Jansen maintains it and you can have full access to the entire documentation at his website − http://www.cwi.nl/~jack/macpython.html. You can find complete installation details for Mac OS installation.


Setting up PATH

Programs and other executable files can be in many directories, so operating systems provide a search path that lists the directories that the OS searches for executables.


The path is stored in an environment variable, which is a named string maintained by the operating system. This variable contains information available to the command shell and other programs.


The path variable is named as PATH in Unix or Path in Windows (Unix is case sensitive; Windows is not).

In Mac OS, the installer handles the path details. To invoke the Python interpreter from any particular directory, you must add the Python directory to your path.


Setting path at Unix/Linux

To add the Python directory to the path for a particular session in Unix −

  • In the csh shell − type setenv PATH "$PATH:/usr/local/bin/python" and press Enter.

  • In the bash shell (Linux) − type export PATH="$PATH:/usr/local/bin/python" and press Enter.

  • In the sh or ksh shell − type PATH="$PATH:/usr/local/bin/python" and press Enter.

  • Note − /usr/local/bin/python is the path of the Python directory


Setting path at Windows

To add the Python directory to the path for a particular session in Windows −

At the command prompt − type path %path%;C:\Python and press Enter.

Note − C:\Python is the path of the Python directory


Characteristics of Python

Following are important characteristics of Python Programming

  • It supports functional and structured programming methods as well as OOP.

  • It can be used as a scripting language or can be compiled to byte-code for building large applications.

  • It provides very high-level dynamic data types and supports dynamic type checking.

  • It supports automatic garbage collection.

  • It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.


Applications of Python

As mentioned before, Python is one of the most widely used language over the web. I'm going to list few of them here:

  • Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This allows the student to pick up the language quickly.

  • Easy-to-read − Python code is more clearly defined and visible to the eyes.

  • Easy-to-maintain − Python's source code is fairly easy-to-maintain.

  • A broad standard library − Python's bulk of the library is very portable and cross-platform compatible on UNIX, Windows, and Macintosh.

  • Interactive Mode − Python has support for an interactive mode which allows interactive testing and debugging of snippets of code.

  • Portable − Python can run on a wide variety of hardware platforms and has the same interface on all platforms.

  • Extendable − You can add low-level modules to the Python interpreter. These modules enable programmers to add to or customize their tools to be more efficient.

  • Databases − Python provides interfaces to all major commercial databases.

  • GUI Programming − Python supports GUI applications that can be created and ported to many system calls, libraries and windows systems, such as Windows MFC, Macintosh, and the X Window system of Unix.

  • Scalable − Python provides a better structure and support for large programs than shell scripting.


Advantages and Disadvantages:


1. Extensive Libraries

Python downloads with an extensive library and contains code for various purposes like regular expressions, documentation-generation, unit-testing, web browsers, threading, databases, CGI, email, image manipulation, and more. So, we don’t have to write the complete code for that manually.


2. Extensible

Python can be extended to other languages. You can write some of your code in languages like C++ or C.

This comes in handy, especially in projects.


3. Embeddable

Complimentary to extensibility, Python is embeddable as well. You can put your Python code in your source code of a different language, like C++. This lets us add scripting capabilities to our code in the other language.


4. Improved Productivity

The language’s simplicity and extensive libraries render programmers more productive than languages like Java and C++ do. Also, the fact that you need to write less and get more things done.


5. IOT Opportunities

Since Python forms the basis of new platforms like Raspberry Pi, it finds the future bright for the Internet Of Things. This is a way to connect the language with the real world.


6. Simple and Easy

When working with Java, you may have to create a class to print ‘Hello World’. But in Python, just a print statement will do. It is also quite easy to learn, understand, and code.


7. Readable

Because it is not such a verbose language, reading Python is much like reading English. This is the reason why it is so easy to learn, understand, and code. It also does not need curly braces to define blocks, and indentation is mandatory. This further aids the readability of the code.


8. Object-Oriented

This language supports both the procedural and object-oriented programming paradigms.

While functions help us with code reusability, classes and objects let us model the real world.

A class allows the encapsulation of data and functions into one.


9. Free and Open-Source

Python is freely available. But not only can you download Python for free, but you can also download its source code, make changes to it, and even distribute it. It downloads with an extensive collection of libraries to help you with your tasks.


10. Portable

When you code your project in a language like C++, you may need to make some changes to it if you want to run it on another platform. But it isn’t the same with Python. Here, you need to code only once, and you can run it anywhere. This is called Write Once Run Anywhere (WORA). However, you need to be careful enough not to include any system-dependent features.


11. Interpreted

Lastly, we will say that it is an interpreted language. Since statements are executed one by one, debugging is easier than in compiled languages.



Source: Tutorialpoint, Wikipedia


The Tech Platform

0 comments

Recent Posts

See All

Comentários


bottom of page