Uploaded by Utkarsh Kumar

python (1)

advertisement
History of Python
Python is a widely-used general-purpose, high-level programming language. Python
was created by Guido van Rossum, and first released on February 20, 1991. The name of the
Python programming language comes from an old BBC television comedy sketch series called
Monty Python's Flying Circus. When it was released, it used a lot fewer codes to express the
concepts, when we compare it with Java, C++ & C. Its main objective is to provide code
readability and advanced developer productivity. When it was released it had more than
enough capability to provide classes with inheritance, several core data types exception
handling and functions.
For various purposes such as developing, scripting, generation, and software testing, this
language is utilized. Due to its elegance and simplicity, top technology organizations like
Dropbox, Google, Quora, Mozilla, Hewlett-Packard, Qualcomm, IBM, and Cisco have
implemented Python.
At pycon22 (python conference) a new feature was released by Anaconda foundation it’s
known as pyscript with this now python can be written and run in the browser like javascript
which was previously not possible, but it still has that unknown charm & X factor which can
be clearly seen from the fact that Google users have consistently searched for Python.
Python Features
Python is a dynamic, high-level, free open source, and interpreted programming language. It
supports object-oriented programming as well as procedural-oriented programming.
1. Free and Open Source
Python language is freely available at the official website. Download Python Since it is opensource; this means that source code is also available to the public. So you can download it, use
it as well as share it.
2. Easy to code
Python is a high-level programming language. Python is very easy to learn the language as
compared to other languages like C, C#, JavaScript, Java, etc. It is very easy to code in the
Python language. It is also a developer-friendly language.
3. Easy to Read
Learning Python is quite simple. Python’s syntax is really straightforward. The code block is
defined by the indentations rather than by semicolons or brackets.
4. Object-Oriented Language
One of the key features of Python is Object-Oriented programming. Python supports objectoriented language and concepts of classes, object, encapsulation, etc.
5. GUI Programming Support
Graphical User interfaces can be made using a module such as PyQt5, PyQt4, wxPython, or Tk in
python. PyQt5 is the most popular option for creating graphical apps with Python.
6. High-Level Language
1|Page
Python is a high-level language. When we write programs in Python, we do not need to
remember the system architecture, nor do we need to manage the memory.
7. Extensible feature
Python is an Extensible language. We can write some Python code into C or C++ language and
also we can compile that code in C/C++ language.
8. Easy to Debug
Its have excellent information for mistake tracing. You will be able to quickly identify and
correct the majority of your program’s issues once you understand how to interpret Python’s
error traces. Simply by glancing at the code, you can determine what it is designed to perform.
9. Python is a Portable language
Python language is also a portable language. For example, if we have Python code for windows
and if we want to run this code on other platforms such as Linux, UNIX, and Mac then we do
not need to change it, we can run this code on any platform.
10. Python is an integrated language
Python is also an integrated language because we can easily integrate Python with other
languages like C, C++, etc.
11. Interpreted Language:
Python is an Interpreted Language because Python code is executed line by line at a time. Like
other languages C, C++, Java, etc. there is no need to compile Python code this makes it easier
to debug our code. The source code of Python is converted into an immediate form called byte
code.
12. Large Standard Library
Python has a large standard library that provides a rich set of modules and functions so you do
not have to write your own code for every single thing. There are many libraries present in
Python such as regular expressions, unit-testing, web browsers, etc.
13. Dynamically Typed Language
Python is a dynamically-typed language. That means the type (for example- int, double, long,
etc.) for a variable is decided at run time not in advance because of this feature we don’t need
to specify the type of variable.
14. Frontend and backend development
With a new project py script, you can run and write Python codes in HTML with the help of
some simple tags <py-script>, <py-env>, etc. This will help you do frontend development work
in Python like javascript. Backend is the strong forte of Python it’s extensively used for this work
cause of its frameworks like Django and Flask.
15. Allocating Memory Dynamically
In Python, the variable data type does not need to be specified. The memory is automatically
allocated to a variable at runtime when it is given a value. Developers do not need to write int y
= 18 if the integer value 18 is set to y. You may just type y=18.
2|Page
Need of Python Programming /Where to use Python?
Even though Python started as a general-purpose programming language with no particular
application as its focus, it has emerged as the language of choice for developers in some
application areas over the last few years. Some important applications of Python are
summarized below:
Data Science
Python experienced a recent emergence in popularity charts, mainly because of its Data
science libraries. A huge amount of data is being generated today by web applications,
mobile applications, and other devices. Companies need business insights from this data.
Today Python has become the language of choice for data scientists. Python libraries
like NumPy, Pandas, and Matplotlib are extensively used in the process of data analysis,
including the collection, processing and cleansing of data sets, applying mathematical
algorithms, and generating visualizations for the benefit of users. Commercial and
community Python distributions by third-parties such as Anaconda and ActiveState provide
all the essential libraries required for data science.
Machine Learning
This is another key application area of Python. Python libraries such as Scikitlearn, Tensorflow and NLTK are widely used for the prediction of trends like customer
satisfaction, projected values of stocks, etc. Some of the real-world applications of machine
learning include medical diagnosis, statistical arbitrage, basket analysis, sales prediction, etc.
Web Development
This is another application area in which Python is becoming popular. Web application
framework libraries like django, Pyramid, Flask, etc. make it very easy to develop and deploy
simple as well as complex web applications. These frameworks are used extensively by
various IT companies. Dropbox, for example, uses Django as a backend to store and
synchronize local folders.
Today, most of the web servers are compatible with WSGI (Web Server Gateway Interface) a specification for the universal interface between Python web frameworks and web servers.
All leading web servers such as Apache, IIS, Nginxetc can now host Python web applications.
Google's App Engine hosts web applications built with almost all Python web frameworks.
Image Processing
The OpenCV library is commonly used for face detection and gesture recognition. OpenCV is
a C++ library but has been ported to Python. Because of the rapid development of this
feature, Python is a very popular choice from image processing.
4.6M
Get 5000 programming project ideas for your portfolio | Web Development Project Ideas
Game Development
Python is a popular choice for game developers. The PyGame library is extensively used for
building games for desktop as well as for mobile platforms. PyGame applications can be
installed on Android too.
Embedded Systems and IoT
Another important area of Python application is in embedded systems. Raspberry Pi is a very
popular yet low-cost single-board computer. It is extensively used in automation products,
3|Page
robotics, IoT, and kiosk applications. Popular microcontrollers like Arduino are used in many
IoT products and are being programmed with Python. A lightweight version of Python
called Micropython has been developed, especially for microcontrollers. A special
Micropython-compatible controller called PyBoard has also been developed.
Android Apps
Although Android apps are predominantly developed using Android SDK, which is similar to
Java, Python can also be used to develop Android apps. Python's Kivy library has all the
functionalities required for a mobile application.
Automated Jobs
Python is extremely useful and widely used for automating CRON (Command Run ON) jobs.
Certain tasks like backups, defined in Python scripts, can be scheduled to be invoked
automatically by the operating system scheduler to be executed at predefined times.
Python is embedded as a scripting language in many popular software products. This is
similar to VBA used for writing macros in Excel, PowerPoint, etc. Python API is integrated
with Maya, PaintShop Pro, etc.
Rapid Development Tool
The standard distribution of Python, as developed by Rossum and maintained by Python
Software Foundation, is called CPython, which is a reference implementation. Its alternative
implementations - Jython, the JRE implementation of Python and IronPython - the .NET
implementation, interact seamlessly with Java and C#, respectively. For example, Jython can
use all Java libraries such as Swing. So the development time can be minimized by using
simpler Python syntaxes and Java libraries for prototyping the software product .
Python Interpreter: Shell/REPL
Python is an interpreter language. It means it executes the code line by line. Python provides
a Python Shell, which is used to execute a single Python command and display the result.
It is also known as REPL (Read, Evaluate, Print, and Loop), where it reads the command,
evaluates the command, prints the result, and loop it back to read the command again.
To run the Python Shell, open the command prompt or power shell on Windows and
terminal window on Mac, write python and press enter. A Python Prompt comprising of
three greater-than symbols >>> appears, as shown below.
4|Page
Python Shell/REPL
Now, you can enter a single statement and get the result. For example, enter a simple
expression like 3 + 2, press enter and it will display the result in the next line, as shown
below.
Execute Python Commands in Shell
Execute Python Script
5|Page
As you have seen above, Python Shell executes a single statement. To execute multiple
statements, create a Python file with extension .py, and write Python scripts (multiple
statements).
For example, enter the following statement in a text editor such as Notepad.
Example: myPythonScript.py
Copy
print ("This is Python Script.")
print ("Welcome to Python Tutorial by TutorialsTeacher.com")
Save it as myPythonScript.py, navigate the command prompt to the folder where you have
saved this file and execute the python myPythonScript.py command, as shown below. It will
display the result.
Thus, you can execute Python expressions and commands using Python REPL to quickly
execute Python code.
6|Page
Download