Intro to Python

Python is a high level, general purpose programming created by Guido Van Rossum. It was publicly released in 1991. By high level, we mean a language which hides nitty-gritty details from the programmer. Further, It also used to refer to a Computer language which is easy to understand for humans. Python is known for known for its simplicity and readability.

Features of Python

Python is Easy

Python is one of the easiest languages to get started with. Programs written in Python looks very much like the English language. Because of its simplicity, most entry-level programming courses use Python to introduce programming concepts to their students.

Python is Portable/Platform Independent

Python is portable which means we can run Python programs in the various different operating system without any changes.

Python is an Interpreted Language

Python is an Interpreted language. Languages like C, C++ are examples of compiled language.

Programs written in a high-level language are called source code or source program and the commands in the source code are called statements. A computer can’t execute a program written in high-level language, it only understands machine language which consists of 0s and 1s only.

There are two types of programs available to us to translate a high-level language to machine language:

  1. Compiler
  2. Interpreter

Compiler

A compiler translates the entire source code into machine language in one go, the machine language is then executed.

program-execution-by-compiler

Interpreter

An interpreter, on the other hand, translates high-level language into machine language line by line, which it then executes. Python Interpreter starts at the top of the file, translates the first line into machine language and then executes it. This process keeps repeating until the end of the file is reached.

program-execution-by-interpreter

Compiled languages like C, C++ uses a compiler to translate the high-level code to machine language, while an interpreted language like Python uses an interpreter to translate the high-level code to machine language.

Another important distinction between Compiled and Interpreted language is that the compiled languages perform slightly better than programs written using interpreted languages. However, I do want to point out that this advantage of Compiled languages is slowly fading away.

Python is Strongly Typed

Strongly typed languages don’t convert data from one type to another type automatically. Languages like JavaScript and PHP, are called loosely typed languages because they convert data from one type to another type freely. Consider the following JavaScript code:

Output:

In this case, before adding 12 to the string; JavaScript first converts number 12 to string "12" and then appends it to the end of the string.

However, In Python statements like str = "The total price = " + 12 would produce an error because Python doesn’t automatically convert number 12 to string.

Huge set of libraries

Python has a huge set of libraries which makes it easy to add new capabilities without reinventing the wheel. We can access these libraries at https://pypi.python.org/pypi.

Here are two common question I hear from beginner Python programmers.

What type of application I can create using Python?

We can use Python to create the following kinds of applications:

  1. Web applications
  2. Android applications
  3. GUI applications
  4. Games
  5. Scientific applications
  6. System administration applications
  7. Console applications

and the list goes on …

Who uses Python?

The following is a small list of well-known Companies who use Python:

  1. Dropbox
  2. Disqus
  3. Reddit
  4. Quora
  5. Mozilla
  6. Google
  7. Youtube

I think that would be enough to impress you.

In the next lesson, we will learn how to install Python.

Note: The source code of this tutorial is available at https://github.com/overiq/intro-to-python.

3 thoughts on “Intro to Python

  1. “Compiled and Interpreted language is that the compiled languages perform slightly better than programs written using interpreted languages. However, I do want to point out that this advantage of Compiled languages is slowly fading away.”

    How is it fading away?

    • As performance of compilers improves, the pre-compilation advantage asymptotically approaches 0.

      Python is a hybridized scripting language. When you run a py file, it checks if the pyc already exists (& is current); if so, it skips compile & runs the pyc. In this case, the compilation advantage is already pretty well nullified. If not, then the py is compiled to a (fresh) pyc, & that is run; this is a bit of runtime overhead, but it only happens once per update / runtime env — so again, the disadvantage is shrinking for the 1st run, and by the second it’s effectively 0.

Leave a Comment