PYTHON
- Python is a general purpose, dynamic, interpreted, interactive, object oriented and high-level programming language.
- It is a free open-source language.
- It supports the oops principles as supported by c++, java
- Like Perl programming, python source code is also available under the GNU General Public License (GPL)
- Python is a modern powerful interpreted language with objects, modules, threads, exceptions, and automatic memory managements
- It is a one-way language system. It does not support compilation. It supports only interpretation.
FEATURES OF PYTHON
- Simple and Easy
- Python is a simple language and easy to learn
- Free / Open Source
- Python language is freely available at the official web site.
- Python is a free open-source language, means that everybody can use python without purchasing license
- The source code is also available. Therefore, it is an open-source language
- Interpreted Language
- Python is a one-way language system. It supports only interpreter.
- Python is a dynamic and interpreted object-oriented scripting language
- Python code is processed at runtime by the interpreter
- No need to compile the source code before executing the programs
- Interpreter executes the code line by line at a time.
- Interactive
- We can execute python commands with help of python interactive interpreter
- We can directly interact with python interpreter to write programs using python prompt
- Object Oriented
- Python supports the features of both procedure-oriented programming and object oriented programming
- It supports single and multiple inheritance
- Polymorphism is supported via runtime interpretation
- Multi-purpose Language
- It supports the creation of web applications, windows GUI applications, database applications, etc, …
- Portable
- Python codes are machine and platform independent
- Python has been ported to several platforms
- We can use python on linux, windows, mac, solaris, OS/2, BeOS, Palm OS, QNX, etc, …
- Embedded Language
- It is possible to embed python codes within C/C++ codes and can be used as a scripting language
- Large Standard Library
- Python has a large set of library collection and provides the rich set of built-in module and functions for rapid application development
- Data Structures Support
- Python supports lot of data structures like lists, sets & dictionaries
PYTHON FAMILY
WHO USES PYTHON
- Amazon
- Uber
- Dropbox, etc,…
FIRST RELEASE
- The first version of python (0.9.0) was released in 20th February 1991
- Guido Van Rossum is the creator of python language.
PYTHON RELEASES
- Python 1.0 released in 1994
- Python 2.0 released in 2000
- Python 3.0 released in 2008
- Python 3.5 released in 2015
- Python 3.6 released in 2016
- Python 3.7 released in 2018
- Python 3.8 released in 2019
- Python 3.9 released in 2020
- Python 3.10 released in 2021
- Python 3.11 released in 2022 (current version)
FILE FORMAT
- Python programs are saved with the “.py” extension.
PYTHON FLAVORS
- Python has a lot of implementations like CPython, JPython, IronPython, etc,.
S.N | IMPLEMENTATION | VIRTUAL MACHINE | LANGUAGE |
1. | CPython | CPythonVM | C Language |
2. | Jython | JVM | Java |
3. | IronPython | CLR | C# |
4. | RubyPython | RubyVM | Ruby |
1. Cpython
- The base of all these implementation (flavors) is CPython or more formally called as Python
- It was developed (Written) in C language and is a bytecode interpreter (bytecodes are executed on CPython Virtual Machine)
2. Jython (JPython)
- It is an implementation of the python targeting the java platform
- It was developed (Written) in java and runs on java virtual machine (JVM)
3. IronPython
- It is an implementation of the python targeting the .NET framework
- It was entirely written in c# and runs on .NET virtual machine (CLR)
- IronPython can use .NET framework and python libraries, providing python developers with the power of the .NET framework
4. RubyPython
- It is an implementation of the python targeting the ruby platform
- It was developed (Written) in ruby and runs on ruby virtual machine (RubyVM)
PYTHON VERSION
- Python language has two versions. They are:
- Python 2.x
- Python 3.x
Python 2.x
- Python 2.x is legacy
- Python 2.x is no longer in development and all new features will be added in python 3
Python 3.x
- Python 3.x is the present and future of the language
Usage of Python
- Python is used in various areas. They are
- Web Development
- Artificial Intelligence
- Machine Learning
- Neural Networks, Robotics
- Natural Language Processing
- Internet of Things (IOT)
- Big Data, AI, NLP, IOT
- Data Science
- Data Analysis and Visualization
- Desktop GUI Development
- Game Development, etc,…
10 REASONS TO LEARN PYTHON
DIFFERENCE BETWEEN PYTHON AND JAVA
S.N | PYTHON | JAVA |
1. | Language Type: Python is a one-way language. It supports only interpretation and does not support compilation | Language Type: Java is a two-way language system. It supports both compilation and interpretation |
2. | Type System: It supports dynamic typed system. No need to mention the data type in the creation of variables and methods Ex. i=99 | Type System: It supports static typed system. Data type must be provided in the creation of both variables and methods Ex. int i=95; |
3. | Semicolon: No need to use semicolon at the end of the statement in python | Semicolon: Semicolon is needed at the end of every statement in java |
4. | Python uses indentation to separate code into blocks Ex. def disp(): print(“Hello World”) Indentation also improves the readability of code | Java uses curly braces to define the start and end of each function and class definition Ex. public void disp() { // user code } |
5. | Speed: Python is slower than java, because of interpreter | Speed: Java is faster than python |
6. | Database: Python’s database access layers are weaker than java’s JDBC. So that, it rarely used in enterprises | Database: Java Database Connectivity (JDBC) is most popular and widely used to connect with database |
7. | main() function: main() is an optional section in python | main() function: main() is an compulsory section in java |
8. | Filename: Filename: .py extension | Filename: Filename: .java extension |
IDE [INTEGRATED DEVELOPMENT ENVIRONMENT] SUPPORT
- Visual Studio IDE → Python, IronPython
- PyCharm IDE → Python
- Eclipse IDE → Python
- Sharp Develop IDE → IronPython
- Netbeans IDE → Java Python
Online Cloud IDE
- Repl.it (http://repl.it/) → Python
Editor
- Visual Studio Code (VSC) → Python
PYTHON APPLICATION TYPES
- Python supports various types of applications
1. Console Application
- Creating an application without any graphical component, that is called as console application
2. Desktop GUI Application
- Creating an application, with use of graphical components is called as windows GUI Application (windows forms application)
- It is an offline application: possible to run the windows GUI application in a particular machine at a time
- Python supports the windows GUI application with help of GUI frameworks
- Popular Python Window GUI Frameworks
- Kivy, PyQT
- Tkinter, WxPython
- PyGUI
- PySide.
3. Web GUI Application
- Creating an application, with use of web graphical components is called as web GUI application (Internet application)
- It is an online application: possible to run the web application in all machine at a time via internet access
- Python is used to build server-side web applications (dynamic web applications)
- Python supports the internet or web GUI application with help of GUI frameworks
- Popular Python Web GUI Frameworks
- Django
- Flask
- Pyramid
- TurboGears
- Web2Py, etc,…
4. Database Application
- Creating an application, with use of database components that is called as database application
- Python supports database applications. It supports various databases like Sqlite, MySQL, Oracle, Sybase, PostgreSQL, etc, …
- Popular open-source databases
- Sqlite DB
- It is built-in database (embedded in python language)
- It stores the data in a single file.
- It is very easy to connect sqlite database
- PostgreSQL
- It is an object relational database management system
- MongoDB
- It is free open source, cross platform database
- It is a NoSQL database
- It is a document-based database
- MySQL
- It is open-source RDBMS
- It is commonly used for web applications.
5. Business Application
- Python is used to build business applications like ERP and E-commerce Systems
- Tryton is a high-level application platform
6. Multimedia Application
- Python is used to develop multimedia applications like audio or video based applications
Example
7. Scientific and Numeric
- Python is popular and widely used in scientific and numeric computing
- Some of the useful library and packages:
- SciPy
- Pandas
- IPython
- SciPy is a group of packages of engineering, science and mathematics.
PYTHON PROGRAM STRUCTURE
- DOCUMENTATION SECTION
- It is an optional section
- It gives complete information about the python program like name of the program, author name, date, version & other details, etc, …
- Python supports two comment statements.
Example
- SYSTEM MODULES
- It is an optional section
- It is used to load the predefined python libraries using “import” keyword
- It is used to create different types of applications, algorithms, tools, OS, etc
- The reserved keyword import is used to load entire module
- Example: sys, msvcrt, datetime, etc, …
Syntax
import <package-name>
Example
import msvcrt
import exceptions
import datetime
- EXECUTABLE SECTION
- It is a mandatory section
- Python code needs at least one executable statement to start the program execution
- In python, execution always starts from top to bottom order.
Example
print(“Good Morning”)
- FUNCTION SECTION
- It is an optional section
- It is used to execute group of statements
- In python, the function is created with the help of reserved keyword def.
- CLASS SECTION
- It is an optional section
- Collection of variables and methods are grouped together into a single entity called as class
- All the variables, methods in the classes are public by default
- Classes are defined using “class” keyword
- It is an important to note that, class should be terminated by the colon (:) operator
- It also supports constructors (parameter & parameter less types)