Introduction to Python

Introduction to Python

In this article, I am going to give you a brief introduction to Python. As part of this article, you will understand the following pointers in detail.

  1. What is python?
  2. Why the name Python?
  3. History of Python
  4. Python Versions
  5. Why python?
  6. Interpreter
  7. Keywords
  8. Flavors
What is python?

Before knowing about the python language, let’s make ourselves familiar with some terms which will help us in understanding Python better.

High-level language vs low-level language

High-level programming languages are those which are programmer-friendly. Humans can easily understand it which helps in easy maintaining and debugging of the code. These types of languages need a compiler or interpreter for execution. High-level languages are the most commonly used languages. Examples – Java, C, C++, Python

Low-level programming languages are those which are machine-friendly. Humans can’t understand such languages. In other words, low-level languages are not human readable. So these languages, comparatively, are complex to debug. An assembler is required to debug these types of languages. Examples – Assembly language, Machine language.

Compiler vs Interpreter

All the programming languages are converted to machine understandable language for execution. The conversion is taken care of by compilers and interpreters.

Let us consider an example of an Italian movie. For a person, who doesn’t understand Italian and can understand English, there will be two ways to watch the movie. The first way is to watch an English dubbed version of the movie, if available. The second way is to watch the Italian movie with English subtitles. In the second way, the subtitles are displayed scene by scene separately whereas in the first way all the scenes are converted to English. We can compare the first scenario with the compiler and the second one with the interpreter.

A compiler is one that takes the source code and converts it into machine-executable code at once. The processor takes the executable and executes it. The languages which use a compiler are called compiled languages. Compiled languages are faster and more efficient comparatively. Examples – Java, C++

An interpreter is one that runs the code line by line and executes instruction by instruction. The languages which use interpreters are called Interpreted languages. Such languages are slower in terms of execution and less efficient. Examples – PHP, Python, Ruby

Scripting language

A scripting language is a programming language that is interpreted. These types of languages are used in automation, etc. These languages use interpreters and are executed line by line.

Definition of Python:

Python is a general-purpose, interpreted, high-level programming language, a Wikipedia definition. In clear terms, Python

  1. High-level language – It is a human-readable language which easily understandable and easy to debug
  2. Interpreted as well as compiled – Python is basically called an interpreted language, but can also be called a compiled interpreted language. In Python, first, all the source code is at once converted to byte code which is the action of the compiler, and then the byte code is executed by the compiler.
  3. Python is also called a scripting language.
History or Origin of Python
  1. It was invented in the Netherlands in the early ’90s.
  2. Guido Van Rossum was the creator of this beautiful language.
  3. Guido released the first version in 1991.
  4. Python was derived from ABC programming language, a general-purpose programming language.
  5. It is open-source software that can be downloaded freely and the code is customizable as well.
Why the name Python?

There was a TV show by the name Monty Python’s Flying Circus which was a very much popular fun show in the 1970s. While creating Python, Guido also used to read this show’s published scripts. Guido needed a short and a different name for this language, hence he named it “Python”.

Python Versions
  1. Python 1.0V introduced in Jan 1994
  2. Python 2.0V introduced in October 2000
  3. Python 3.0V introduced in December 2008.
  4. The current version is 3.8

Note: Python 3 won’t provide backward compatibility to Python2 i.e. there is no guarantee that Python2 programs will run in Python3.

Features of Python

Simple: Python syntax is very easy. Developing and understanding python is very easy than others. The below comparison illustrated how simple python language is when compared to other languages.

Introduction to Python

Open Source – We can download freely and customize the code as well

Dynamically typed – Dynamically type will be assigned to data.

Platform independent: Python programs are not dependent on any specific operating systems. We can run on all operating systems happily.

Portable: If a program gives the same result on any platform then it is a portable program. Python used to give the same result on any platform.

Huge library – Python has a big library to fulfill the requirements.

Database connectivity – Python provides interfaces to connect with all major databases like oracle, MySQL

Batteries included – Python provides inbuilt libraries called batteries. Some of them are below

  1. Boto – amazon web services library
  2. MySQL-connector-python – To connect with MySQL
  3. NumPy – To process arrays
  4. Pandas – powerful data structures for data analysis, time series, and statistics
Where all python is used?

Python is being used to develop:

  1. Standalone applications: An application that needs to install on every machine to work with that application.
  2. Web applications: An application that follows a client-server architecture. The client is a program, which sends requests to the server. The server is a program, mainly it can do three things. Captures the request from the client, Process the request, and Sends the response to the client
  3. Database applications.
  4. To process huge amounts of data. Ex Hadoop, Spark.
  5. Machine learning.
  6. Artificial Intelligence.
  7. Data science.
  8. Network servers.
  9. IoT
  10. Application scripting etc.
Python supports
  1. Functional programming as well as Object-oriented programming approach.
  2. Initial languages like C, Pascal, or FORTRAN follow functional approaches.
  3. C++, Java, and dot net follow an object-oriented approach.
  4. Python follows both functional and object-oriented approaches.
Python an interpreted language

An interpreter is very different from a compiler. An interpreter executes the statements of code “one-by-one” whereas the compiler executes the code entirely and lists all possible errors at a time. That’s why python shows only one error message even though your code has multiple errors. This will help you to clear errors easily.

Keywords in Python

All keywords in python contain only alphabet symbols. All of them are in lower case except True, False, and None. To see all the keywords –

  1. import keyword;
  2. keyword.kwlist

Keywords – [‘False’, ‘None’, ‘True’, ‘and’, ‘as’, ‘assert’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’, ‘except’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘nonlocal’, ‘not’, ‘or’, ‘pass’, ‘raise’, ‘return’, ‘try’, ‘while’, ‘with’, ‘yield’]

Keyword is a module in python
S.NoFlow ControlException HandlingClassFunctions and methodsVariableObjectModuleMembershipBuild-in ConstantsLogical
1iftryclassdefglobaldelimportisTrueand
2elseexceptwithnonlocalfrominFalseor
3elifraiselambdaasNonenot
4forfinally
5whileassert
6break
7continue
8return
9yield
10pass
Different flavors of python

Flavors of python refer to the different types of python compilers. These are useful to integrate various programming languages.

  1. CPython: Standard python compiler implemented in C language. This is the python software being downloaded and used by the programmers directly.
  2. Jython: Initially called as JPython, later renamed to Jython. Designed to run on a Java program.
  3. IronPython: Designed for .NET framework.
  4. PyPy: The main advantage of PyPy is performance will be improved because the JIT compiler is available inside PVM.
  5. RubyPython: This is a bridge between Ruby and Python interpreters. It encloses a python interpreter inside the Ruby application.
  6. AnacondaPython: Anaconda is a free and open-source Python programming language. This is mainly for data science and machine learning-related applications (large-scale data processing, predictive analytics, scientific computing). This aims to simplify package management and deployment.

In the next article, I am going to discuss Python Coding Instructions. Here, in this article, I try to give an overview of Python Introduction. I hope you enjoy this article. I would like to have your feedback. Please post your feedback, question, or comments about this article.

1 thought on “Introduction to Python”

  1. The introduction is awesome. I used to read books on how to learn this type of programming, and it was very hard for me to catch up. With these tutorials, I begin to see how enjoyable the learning is going to be. How you make use of practical life examples to explain some of the concepts, makes the learning even easier and enjoyable.

Leave a Reply

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