Python Programming - Introduction to Python Language

Python Programming – Introduction to Python Language

We see that computers are capable of solving numerous problems in the real world. The problems can be as simple as multiplying two numbers or as cumbersome as designing and launch a space shuttle. This would be incorrect to assume that the computer can do all the tasks on its own. Any problem whose solution is not identified cannot be solved by a computer. The computer merely works on the set of instructions given to it by a programmer. If the computer does not understand the instructions then errors may occur and a solution cannot be obtained. Therefore, it is the keen responsibility of the programmer to devise a solution by giving correct instructions to the computer.

Programming Language

In order to solve a problem using a computer, the programmer writes the instructions which are understandable by the computer. The computer understands only digital data either ‘0’ or ‘ 1’. The most basic language is the machine language that uses binary ‘0’ and ‘1’, which a computer can understand and execute very fast without using any translator (compiler or interpreter). However, it is quite difficult to code a program in machine language. High-level languages such as (C, C++, Java) are very simple to understand by humans because these languages use English language-like statements. However, an additional program such as a compiler or interpreter is required to convert the high-level language into machine language. Therefore, high-level languages are slower than machine languages.

In other words, we can say that people express themselves using a language that has many words. Computers use a simple language that consists of strings of Os and Are, with a 1 representing “on” and a 0 representing “off.”. The programming language works as a translator between you and the computer. Rather than learning the computer’s native language (called machine language), one can make use of a programming language to instruct the computer in a way that is easier to learn and understand.

Every programming language has a particular structure with specific syntax and semantics. Programming language is something like a code for writing down the instructions that a computer will follow. In fact, programmers often refer to their programs as computer code or the process of implementing an algorithm. Alike other high-level languages such as C, C++, Java, Python is also a programming language. In this book, we will learn the Python programming language in detail.

History of Python Language

Python is a very powerful high-level, object-oriented programming language. It was developed by Guido Van Rossum during 1985-1990 at the national research institute for mathematics and computer science in the Netherlands. It is the derivative of several other languages such as ABC, Modulo-3, C, C++, Algol-68, Smalltalk, and Unix Shell. ABC is a general-purpose programming language or programming environment, which had been developed in the Netherlands, Amsterdam, at the CWI (Centrum Wiskunde & Informatica). The greatest achievement of ABC was to influence the design of Python.

The source code of Python language is available under GNU i.e., General Public License (GPL). Python is a very easy-to-use language with simple syntax, which makes it a perfect language for beginners. It is an interpreter-based language. The interpreter is a program that converts the high-level programs into low-level programs, i.e., machine code. It is designed to be highly readable because it uses English keywords very frequently whereas other languages use punctuations. Moreover, it has fewer syntactical constructions than other languages.

Guido Van Rossum published the first version of Python code (version 0.9.0) in February 1991. This release included already exception handling, functions, and the core data types of list, diet, strand others. Python was developed to be a module as well as an object-oriented language. Another version 1.0 of Python was released in January 1994. The major new features included in this release were the functional programming tools lambda, map, filter and reduce, which Guido Van Rossum never liked. Six and a half years later in October 2000, Python 2.0 was introduced. This release included list comprehensions, a full garbage collector and it had the support for Unicode. Python flourished for another 8 years in version 2.x before the next major release as Python 3.0 (also known as “Python 3000” and “Py3K”). Python 3 is not backward compatible with Python 2.x. The emphasis in Python 3 had been on the removal of duplicate .programming constructs and modules.

Origin of Python Programming Language

At the time when he began implementing Python, Guido van Rossum was reading the published scripts from “Monty Python’s Flying Circus” (a BBC comedy series from the seventies). It occurred to him that he needed a name that should be short, unique, and slightly mysterious, so he decided to call the language Python.

Limitations of Python

As we see, Python language has many features, it has some limitations also as under:

  • Python is an interpreter-based language. Therefore, it is a bit slower than compiler-based languages.
  • Since Python is a high-level language like C/C++/Java, it also uses many layers to communicate with the operating system and the computer hardware.
  • Graphics-intensive applications such as games make the program run slower.

Major Applications of Python

The list of companies that use Python includes the following:

  • Yahoo! (for Yahoo! Maps)
  • t Google (for its spider and search engine)
  • Linux Weekly News (published by using a web application written in Python)
  • Industrial Light & Magic (used in the production of special effects for movies such as The Phantom Menace and The Mummy Returns).

Getting Python

The most up-to-date and current source code, binaries, documentation, news, etc., is available on the official website of Python: http://www.pvthon.org/
The complete Python documentation can be obtained from the following site www.python.ora/doc/. The documentation is available in HTML, PDF, and PostScript formats.

Python Environment Variables

Here are important environment variables, which can be recognized by
Python:

  • PYTHONPATH: This variable plays a similar role as PATH. It is sometimes preset by the Python installer. Its task is to tell the Python interpreter where to locate the module files imported into a program. It must include the source library directory and directories containing Python source codes.
  • PYTHONSTARTUP: It contains the path of an initialization file containing Python source code. It is executed every time you start the interpreter. It is named as .pythonrc.py in Unix and it comprises commands that load utilities or modify PYTHONPATH.
  • PYTHONCASEOK: It is used in Windows to instruct Python to find the first case-insensitive match in an import statement. In order to activate this variable set it to any value.
  • PYTHONHOME: It is another module search path. It is usually embedded in the PYTHONSTARTUP or PYTHONPATH directories to make switching module libraries easy.

Summary

In this chapter, we have learned about the programming language and its need. Then we have given a brief look at the origin and history of the Python language along with its features and limitations. Then we have explored in detail that how Python language differs from other existing and prominent programming languages such as C, C++, and Java. The setup and installation of Python language along with a simple first program are also discussed in detail.

Python Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *