top

Search

Python Tutorial

Python is a general-purpose high-level language. Well this description applies to almost every other language a computer science student knows. So why has Python’s popularity risen tremendously in last few years? According to TIOBE (which stands for “The Importance Of Being Earnest”) programming community index, Python currently (as on September 2018) ranks third only behind Java and C. (ref: https://www.tiobe.com/tiobe-index/python/) The index is calculated taking various search engine results into account.Primary objective of any computer program is to automate a repetitive task. However, development cycle of some of the popular languages is extremely tedious and slow. This is where Python scores over them. Python is very easy to use. It has a very clean and uncomplicated syntax. Hence it will get the job done for you more quickly than most other languages.S:NoTitle1Python - Getting Started2Python - Basic Syntax3Python - Variables4Python - Numbers5Python - Strings6Python - List And Tuple7Python - Dictionary8Python - Sets9Python - Operators10Python - Conditional Statements11Python - Loops12Python - Built-In Modules13Python - User Defined Functions14Python - Functional Programming15Python - Custom Modules16Python - Packages17Python - Exceptions18Python - FileIO19Python - CSV20Python - Database Connectivity21Python – Tkinter22Python - Object Oriented Programming23Python - Decorators24Python - Inheritance25Python - Magic Methods26Python - Regex27Python - CGI28Python - Send Email29Python - Object Serialization30Python - Multithreading31Python - XML32Python - Socket Module33Python - Data ClassesMain features:Simplicity: ‘Simple is better than complex’. This is one of the guiding principles behind design philosophy of Python. The collection of software principles that influence the design philosophy of Python is illustrated by ‘Zen of Python’ ( https://www.python.org/dev/peps/pep-0020/#id3 ). They can be viewed by entering “import this” from Python prompt>>> import thisIn C/C++/Java etc. writing a simple ‘Hello World’ program can be very daunting for the beginner because of rather too elaborate syntax, clumsy use of curly brackets and the fact that the code should be compiled before execution. In contrast, Python instructions can be executed straight away, from the Python shell itself.Free and open source: Python software can be freely downloaded from its official website www.python.org. Its source code is also available; hence a large number of developers are actively involved in development and support of Python libraries for various applications. Many alternative distributions such as Anaconda and implementations such as Jython have come up as a result.Interpreter based: Python instructions are executed even from Python prompt just as OS commands. This helps in rapid prototyping of applications. Python scripts are not compiled. As a result, execution of Python program is slower than C/C++/Java programs. However it is possible to build a self executable from Python script using tools such as PyInstaller.Cross-platform: Python can be installed on all prominent operating system platforms such as Windows, Linux, MacOS etc. Python program developed on one OS environment runs seamlessly on others.Multi-paradigm: Python supports procedural, object oriented as well as functional programming styles.Compact: More often than not, Python code is smaller size as compared to equivalent code (performing same process) in C/C++/Java. This is mainly because of functional programming features such as list comprehension, map and reduce functions etc.Extensible: Standard distribution of Python is bundled with several built-in modules having functions ranging from statistics, regex, socket handling, serialization etc. However, customised modules can be added in the library. These modules may be written in C/C++/Java or Python.Dynamically typed: Python program doesn’t need prior declaration of name and type of variable, as is the case in C/C++/Java etc.Where is Python used?As mentioned before, Python is a general purpose language. Moreover, its extensibility makes it possible to use it for all kinds of applications. Some key application areas are listed below:Data science: The surge in popularity of Python in the recent past is primarily because of its application in data science. Although data science is a very broad term, it basically means analysis and visualization of large amount of data that is nowadays generated by widespread use of web and mobile applications as well as embedded products.Special-purpose libraries like Numpy, Pandas and Matplotlib etc. have become important tools for data scientists. Commercial as well as community distributions of Python in the form of Anaconda, Canopy and Activestate bundle all required libraries for numerical and scientific computing.Machine learning: This is another area in which Python is becoming popular. Special purpose Python libraries such as Scikit-Learn and TensorFlow have capability to predict trends based on past data regarding customer behaviour, stock market, electioneering etc.Image processing: Face detection and gesture recognition using opencv library and Python is another important application. Opencv is a c++ library, but has been ported to Python. This library has lot of extremely powerful image processing functions.GUI interface: Almost all popular GUI toolkits have their Python port. Standard distribution of Python is bundled with Tkinter. Qt library has been ported to python in the form of PyQt. So is GTK, OpenGL and others. Using these toolkits, attractive GUI interfaces can be designed.Data based applications: Almost all RDBMS products e.g. Oracle, MySQL, SQL Server etc. can be used as a back and for Python program. Python library has in-built support for SQLite. Python recommends a uniform DB-API standard based on which database interfacing libraries have been developed for each database type.Embedded systems and IoT: Another important area of Python application is in embedded systems. Raspberry Pi and Arduino based automation products, robotics, IoT, and kiosk applications are programmed in Python.Automation scripts: Python is a popular choice for writing scripts for scheduled jobs to be performed by servers. Python is also embedded in software products like Maya and Paintshop Pro to define macros.Web applications: Python based toolkits for rapid web application development are very popular. Examples are Django, Flask, Pyramid etc. These applications are hosted on WSGI compliant web servers such as Apache, IIS etc.Who uses Python?Many software giants have adopted Python as their main development platform. Some prominent ones are as follows:Google uses Python extensively in many of its applications. Its support is one of the main reasons behind the increasing popularity of Python. Google has contributed immensely by preparing documentations and other resources on Python. Google App Engine is a popular choice for hosting Python based web applications.Facebook, the social media company uses Python particularly in Facebook Ads API, infrastructure management and binary distribution etc.Instagram, a photo and video-sharing social networking platform also uses django framework which is written entirely in Python.Quora, a popular question and answer forum also uses Python frameworks such as django and Pylons.Dropbox, a cloud based storage system uses Python in its desktop client module. Guido Van Rossum, the man who is Python’s principle developer has been working with Dropbox for last few years.Youtube, American video-sharing company now a part of Google conglomerate relies substantially on Python for its functionality.HistoryAlthough Python is extremely popular amongst the modern generation of software professionals, it has a history of more than three decades. Guido Van Rossum, a Dutch programmer conceived and developed this language and published its early version in 1991. Python can be thought as a successor of another language named ABC. According to Rossum, he named his language after a popular BBC TV series titled ‘Monty Python’s Flying Circus’.Python is an open source language. It is released under GPL compatible PSF licence. Python Software Foundation (PSF) owns the copyright of Python.In October 2000, Python’s 2.0 version was released. It contained many features of functional programming paradigm. Since then, successive upgradations of Python 2.x have been published. Most current version in this sequence is Python 2.7.15.  PSF has announced that development, maintenance and support of Python 2.x will be discontinued after 2020 and users are encouraged to adapt Python 3 as early as possible.Python 3.0 was introduced in December 2008. This version was meant to be backward incompatible. However, many of its features have since been back-ported to Python 2.6.x and Python 2.7.x series. Python 3 comes with 2to3 utility to help Python 2.x users covert their code. Current version in this branch is Python 3.7.2
Rated 5/5 based on 11 customer reviews

Python Tutorial

Python Tutorial

logo

Python Tutorial

Python is a general-purpose high-level language. Well this description applies to almost every other language a computer science student knows. So why has Python’s popularity risen tremendously in last few years? According to TIOBE (which stands for “The Importance Of Being Earnest”) programming community index, Python currently (as on September 2018) ranks third only behind Java and C. (ref: https://www.tiobe.com/tiobe-index/python/) The index is calculated taking various search engine results into account.

Primary objective of any computer program is to automate a repetitive task. However, development cycle of some of the popular languages is extremely tedious and slow. This is where Python scores over them. Python is very easy to use. It has a very clean and uncomplicated syntax. Hence it will get the job done for you more quickly than most other languages.

S:No
Title
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

Main features:

Simplicity: ‘Simple is better than complex’. This is one of the guiding principles behind design philosophy of Python. The collection of software principles that influence the design philosophy of Python is illustrated by ‘Zen of Python’ ( https://www.python.org/dev/peps/pep-0020/#id3 ). They can be viewed by entering “import this” from Python prompt

>>> import this

In C/C++/Java etc. writing a simple ‘Hello World’ program can be very daunting for the beginner because of rather too elaborate syntax, clumsy use of curly brackets and the fact that the code should be compiled before execution. In contrast, Python instructions can be executed straight away, from the Python shell itself.

Free and open source: Python software can be freely downloaded from its official website www.python.org. Its source code is also available; hence a large number of developers are actively involved in development and support of Python libraries for various applications. Many alternative distributions such as Anaconda and implementations such as Jython have come up as a result.

Interpreter based: Python instructions are executed even from Python prompt just as OS commands. This helps in rapid prototyping of applications. Python scripts are not compiled. As a result, execution of Python program is slower than C/C++/Java programs. However it is possible to build a self executable from Python script using tools such as PyInstaller.

Cross-platform: Python can be installed on all prominent operating system platforms such as Windows, Linux, MacOS etc. Python program developed on one OS environment runs seamlessly on others.

Multi-paradigm: Python supports procedural, object oriented as well as functional programming styles.

Compact: More often than not, Python code is smaller size as compared to equivalent code (performing same process) in C/C++/Java. This is mainly because of functional programming features such as list comprehension, map and reduce functions etc.

Extensible: Standard distribution of Python is bundled with several built-in modules having functions ranging from statistics, regex, socket handling, serialization etc. However, customised modules can be added in the library. These modules may be written in C/C++/Java or Python.

Dynamically typed: Python program doesn’t need prior declaration of name and type of variable, as is the case in C/C++/Java etc.

Where is Python used?

As mentioned before, Python is a general purpose language. Moreover, its extensibility makes it possible to use it for all kinds of applications. Some key application areas are listed below:

Data science: The surge in popularity of Python in the recent past is primarily because of its application in data science. Although data science is a very broad term, it basically means analysis and visualization of large amount of data that is nowadays generated by widespread use of web and mobile applications as well as embedded products.

Special-purpose libraries like Numpy, Pandas and Matplotlib etc. have become important tools for data scientists. Commercial as well as community distributions of Python in the form of Anaconda, Canopy and Activestate bundle all required libraries for numerical and scientific computing.

Machine learning: This is another area in which Python is becoming popular. Special purpose Python libraries such as Scikit-Learn and TensorFlow have capability to predict trends based on past data regarding customer behaviour, stock market, electioneering etc.

Image processing: Face detection and gesture recognition using opencv library and Python is another important application. Opencv is a c++ library, but has been ported to Python. This library has lot of extremely powerful image processing functions.

GUI interface: Almost all popular GUI toolkits have their Python port. Standard distribution of Python is bundled with Tkinter. Qt library has been ported to python in the form of PyQt. So is GTK, OpenGL and others. Using these toolkits, attractive GUI interfaces can be designed.

Data based applications: Almost all RDBMS products e.g. Oracle, MySQL, SQL Server etc. can be used as a back and for Python program. Python library has in-built support for SQLite. Python recommends a uniform DB-API standard based on which database interfacing libraries have been developed for each database type.

Embedded systems and IoT: Another important area of Python application is in embedded systems. Raspberry Pi and Arduino based automation products, robotics, IoT, and kiosk applications are programmed in Python.

Automation scripts: Python is a popular choice for writing scripts for scheduled jobs to be performed by servers. Python is also embedded in software products like Maya and Paintshop Pro to define macros.

Web applications: Python based toolkits for rapid web application development are very popular. Examples are Django, Flask, Pyramid etc. These applications are hosted on WSGI compliant web servers such as Apache, IIS etc.

Who uses Python?

Many software giants have adopted Python as their main development platform. Some prominent ones are as follows:

Google uses Python extensively in many of its applications. Its support is one of the main reasons behind the increasing popularity of Python. Google has contributed immensely by preparing documentations and other resources on Python. Google App Engine is a popular choice for hosting Python based web applications.

Facebook, the social media company uses Python particularly in Facebook Ads API, infrastructure management and binary distribution etc.

Instagram, a photo and video-sharing social networking platform also uses django framework which is written entirely in Python.

Quora, a popular question and answer forum also uses Python frameworks such as django and Pylons.

Dropbox, a cloud based storage system uses Python in its desktop client module. Guido Van Rossum, the man who is Python’s principle developer has been working with Dropbox for last few years.

Youtube, American video-sharing company now a part of Google conglomerate relies substantially on Python for its functionality.

History

Although Python is extremely popular amongst the modern generation of software professionals, it has a history of more than three decades. Guido Van Rossum, a Dutch programmer conceived and developed this language and published its early version in 1991. Python can be thought as a successor of another language named ABC. According to Rossum, he named his language after a popular BBC TV series titled ‘Monty Python’s Flying Circus.

Python is an open source language. It is released under GPL compatible PSF licence. Python Software Foundation (PSF) owns the copyright of Python.

In October 2000, Python’s 2.0 version was released. It contained many features of functional programming paradigm. Since then, successive upgradations of Python 2.x have been published. Most current version in this sequence is Python 2.7.15.  PSF has announced that development, maintenance and support of Python 2.x will be discontinued after 2020 and users are encouraged to adapt Python 3 as early as possible.
Python 3.0 was introduced in December 2008. This version was meant to be backward incompatible. However, many of its features have since been back-ported to Python 2.6.x and Python 2.7.x series. Python 3 comes with 2to3 utility to help Python 2.x users covert their code. Current version in this branch is Python 3.7.2

Leave a Reply

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

Suggested Tutorials

C# Tutorial

By KnowledgeHut Editor

C# is an object-oriented programming developed by Microsoft that uses the .Net Framework. It utilizes the Common Language Interface (CLI) that describes the executable code as well as the runtime environment. C# can be used for various applications such as web applications, distributed applications, database applications, window applications etc.For greater understanding of this tutorial, a basic knowledge of object-oriented languages such as C++, Java etc. would be beneficial.
Rated 5/5 based on 12 customer reviews
C# Tutorial

C# is an object-oriented programming developed by Microsoft that uses ...

Read More