Introduction to Python
In this article, I am going to give you a brief introduction to 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 an 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
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
- High-level language – It is a 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 ’90s.
- Guido Van Rossum was the creator of this beautiful language.
- Guido released the first version in 1991.
- Python was derived from the ABC programming language, a general-purpose programming language.
- 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 1.0V was introduced in Jan 1994
- Python 2.0V was introduced in October 2000
- Python 3.0V was introduced in December 2008.
- 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.
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
- 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 that needs to install on every machine to work with that application.
- 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
- 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 is 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 –
- 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’]
Different flavors of python
Flavors of python refer 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.