0% found this document useful (0 votes)
24 views7 pages

Python Notes

Uploaded by

Nikita Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views7 pages

Python Notes

Uploaded by

Nikita Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Introduction:

Python is a widely used general-purpose, high level programming language. It was created by
Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was
designed with an emphasis on code readability, and its syntax allows programmers to express
their concepts in fewer lines of code.
Python is a programming language that lets you work quickly and integrate systems more
efficiently.

It is used for:

 web development (server-side),


 software development,
 mathematics,
 system scripting.

History of Python

Python was developed by Guido van Rossum in the late eighties and early nineties at the
National Research Institute for Mathematics and Computer Science in the Netherlands.
Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68,
SmallTalk, and Unix shell and other scripting languages.
Python is copyrighted. Like Perl, Python source code is now available under the GNU General
Public License (GPL).
Python is now maintained by a core development team at the institute, although Guido van
Rossum still holds a vital role in directing its progress.
Features in Python

There are many features in Python, some of which are discussed below as follows:

1. Free and Open Source

Python language is freely available at the official website and you can download it from the
given download link below click on the Download Python keyword. Download Python Since
it is open-source, 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 and anybody can learn Python basics in a few hours or days. It is also a
developer-friendly language.

3. Easy to Read

As you will see, learning Python is quite simple. As was already established, 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 object-
oriented 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

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. Large Community Support

Python has gained popularity over the years. Our questions are constantly answered by the
enormous StackOverflow community. These websites have already provided answers to many
questions about Python, so Python users can consult them as needed.

8. Easy to Debug

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.

command interpreter and development environment- IDLE:


IDLE is Python’s Integrated Development and Learning Environment. It allows
programmers to easily write Python code. Just like Python Shell, IDLE can be used to execute a
single statement and create, modify, and execute Python scripts.

features of Python IDLE?

The principal functions of the Python IDLE are given below -

o Made entirely of Python code and the tkinter GUI toolkit.


o Search across numerous files (grep), alter text within editor windows, and search across
any window.
o Cross-platform, largely same behaviour on Windows, Unix, and macOS
o The interactive Python shell window has coloured input, output, and messages of error.
o Debugging tool featuring stepping, permanent breakpoints, and namespace viewing.
o Very powerful debugger, dialogs, browsers, and configuration.
o Multi undo, Python colorizing, sensible indent, call hints, auto finish, and more features
are included in this multi-window text editor.

Advantages of Python IDLE:

The following are some benefits of utilising Python IDLE:

o Python IDLE is an interactive shell that enables users to easily test and run short bits of
Python code without needing to create a whole programme.
o Python IDLE's code editor has features like syntax highlighting and code completion that
make it simpler and faster to write Python programmes.
o Python IDLE has a built-in debugger that enables programmers to walk through their
code and find faults and problems.
o Python IDLE may be used on Linux, macOS, and Windows thanks to its cross-platform
nature.
o Python IDLE is included with the Python installation, thus users don't need to install any
more programmes in order to begin coding in Python.
o Python IDLE is open-source, free software, which entitles users to use it with no any
limitations for both business and non-commercial uses.

Application of Python:

1) Web Applications

We can use Python to develop web applications. It provides libraries to handle internet protocols
such as HTML and XML, JSON, Email processing, request, beautifulSoup, Feedparser, etc. One
of Python web-framework named Django is used on Instagram. Python provides many useful
frameworks, and these are given below:

o Django and Pyramid framework(Use for heavy applications)


o Flask and Bottle (Micro-framework)
o Plone and Django CMS (Advance Content management)

2) Desktop GUI Applications

The GUI stands for the Graphical User Interface, which provides a smooth interaction to any
application. Python provides a Tk GUI library to develop a user interface. Some popular GUI
libraries are:

o Tkinter or Tk
o wxWidgetM
o Kivy (used for writing multitouch applications )
o PyQt or Pyside

3) Console-based Application

Console-based applications run from the command-line or shell. These applications are computer
program which are used commands to execute. This kind of application was more popular in the
old generation of computers. Python can develop this kind of application very effectively. It is
famous for having REPL, which means the Read-Eval-Print Loop that makes it the most
suitable language for the command-line applications.

4) Software Development
Python is useful for the software development process. It works as a support language and can be
used to build control and management, testing, etc.

o SCons is used to build control.


o Buildbot and Apache Gumps are used for automated continuous compilation and testing.
o Round or Trac for bug tracking and project management.

5) Scientific and Numeric

This is the era of Artificial intelligence where the machine can perform the task the same as the
human. Python language is the most suitable language for Artificial intelligence or machine
learning. It consists of many scientific and mathematical libraries, which makes easy to solve
complex calculations.

Implementing machine learning algorithms require complex mathematical calculation. Python


has many libraries for scientific and numeric such as Numpy, Pandas, Scipy, Scikit-learn, etc. If
you have some basic knowledge of Python, you need to import libraries on the top of the code.
Few popular frameworks of machine libraries are:

o SciPy
o Scikit-learn
o NumPy
o Pandas
o Matplotlib

6) Business Applications

Business Applications differ from standard applications. E-commerce and ERP are an example
of a business application. This kind of application requires extensively, scalability and
readability, and Python provides all these features.

7) Audio or Video-based Applications

Python is flexible to perform multiple tasks and can be used to create multimedia applications.
Some multimedia applications which are made by using Python are TimPlayer, cplay, etc. The
few multimedia libraries are:

o Gstreamer
o Pyglet
o QT Phonon
8) 3D CAD Applications

The CAD (Computer-aided design) is used to design engineering related architecture. It is used
to develop the 3D representation of a part of a system. Python can create a 3D CAD application
by using the following functionalities.

o Fandango (Popular )
o CAMVOX
o HeeksCNC
o AnyCAD
o RCAM

Python 2/3 differences:

 Python 3 syntax is simpler and easily understandable whereas Python 2 syntax is


comparatively difficult to understand.
 Python 3 default storing of strings is Unicode whereas Python 2 stores need to define
Unicode string value with “u.”
 Python 3 value of variables never changes whereas in Python 2 value of the global
variable will be changed while using it inside for-loop.
 Python 3 exceptions should be enclosed in parenthesis while Python 2 exceptions should
be enclosed in notations.
 Python 3 rules of ordering comparisons are simplified whereas Python 2 rules of ordering
comparison are complex.
 Python 3 offers Range() function to perform iterations whereas, In Python 2, the xrange()
is used for iterations.

Basic program structure-quotation and indentation

In Python, indentation is the leading whitespace (spaces or/and tabs) before any statement. The
importance of indentation in Python stems from the fact that it serves a purpose other than code
readability. Python treats statements with the same indentation level (statements preceded by the
same number of whitespaces) as a single code block. So, whereas in languages such as C, C++,
and others, a block of code is represented by curly braces, a block in Python is a group of
statements with the same Indentation level, i.e. the same number of leading whitespaces.

Rules of Indentation in Python

Here are the rules of indentation in python:

 Python’s default indentation spaces are four spaces. The number of spaces, however, is entirely
up to the user. However, a minimum of one space is required to indent a statement.
 Indentation is not permitted on the first line of Python code.

 Python requires indentation to define statement blocks.

 A block of code must have a consistent number of spaces.

 To indent in Python, whitespaces are preferred over tabs. Also, use either whitespace or tabs to
indent; mixing tabs and whitespaces in indentation can result in incorrect indentation errors.

You might also like