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.
- What is python?
- Why the name Python?
- History of Python
- Python Versions
- Why python?
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 mostly 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 Italian movie. For a person, who doesn’t understand italian and can understand English, there will be two ways to watch the movie. First way is to watch a English dubbed version of the movie, if available. 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 which 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 which 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
A scripting language is a programming language which is interpreted. These types of languages are used in automations, 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
- High level language – It is human readable language which easily understandable and easy to debug
- 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.
- Python is also called a scripting language.
History or Origin of Python
- It was invented in the Netherlands in the early 90’s.
- Guido Van Rossum was the creator of this beautiful language.
- Guido released the first version in 1991.
- Python was derived from ABC programming language, a general purpose programming language.
- It is open source software which 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 1970’s. 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 1.0V introduced in Jan 1994
- Python 2.0V introduced in October 2000
- Python 3.0V introduced in December 2008.
- 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.
Open Source – We can download freely and customise 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 fulfil 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
- Boto – amazon web services library
- MySQL-connector-python – To connect with MySQL
- NumPy – To process arrays
- Pandas – powerful data structures for data analysis, time series and statistics
Where all python is used?
Python is being used to develop:
- Standalone applications: An application which needs to install on every machine to work with that application.
- Web applications: An application which follows client-server architecture. Client is a program, which sends requests to the server. Server is a program, mainly it can do three things. Captures the request from client, Process the request, and Sends the response to the client
- Database applications.
- To process huge amounts of data. Ex Hadoop, Spark.
- Machine learning.
- Artificial Intelligence.
- Data science.
- Network servers.
- Application scripting etc.
- Functional programming as well as Object oriented programming approach.
- Initial languages like C, Pascal or FORTRAN follow functional approaches.
- C++, Java and dot net follow an object-oriented approach.
- Python follows both functional and object-oriented approaches.
Python an interpreted language
An interpreter is very different from the 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 –
- import keyword;
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.No||Flow Control||Exception Handling||Class||Functions and methods||Variable||Object||Module||Membership||Build-in Constants||Logical|
Different flavors of python
Flavours of python refers to the different types of python compilers. These are useful to integrate various programming languages.
CPython: Standard python compiler implemented in C language. This is the python software being downloaded and used by the programmers directly.
Jython: Initially called as JPython, later renamed to Jython. Designed to run on a Java program.
IronPython: Designed for .NET framework.
PyPy: The main advantage of PyPy is performance will be improved because the JIT compiler is available inside PVM.
RubyPython: This is a bridge between Ruby and python interpreters. It encloses a python interpreter inside the Ruby application.
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.