Deepak
Deepak
Of
Python
1.What is Python?
The Python programming language is
an object-oriented language, which
means that it can model real-world
entities. It is also dynamically-typed
because it carries out type-checking
at runtime. It does so to make sure
that the type of construct matches
what we expect it to be. The
distinctive feature of Python is that
it is an interpreted language. The
Python IDLE (Integrated Development
Environment) executes instructions
one line at a time. This also lets us
use it as a calculator.
i. Why is it called Python?
Going into etymology, Guido van Rossum
named it after the comedy group Monty
Python. That is why the metasyntactic
variables (those we will often use to
explain code syntax) used here are ‘spam’
and ‘eggs’ instead of ‘foo’ and ‘bar’. A lot
of implementations today run version 2.x,
but the future belongs to Python 3.x. It
is also called ‘Python 3000’ or ‘Py3K’.
CPython, written in C, is the most
common implementation of Python.
ii.Python History
The Python programming language was
conceived in the late 1980s and was named
after the BBC TV show Monty Python’s Flying
Circus. Guido van Rossum started implement-
ing Python at CWI in the Netherlands
in December of 1989. This was a successor
to the ABC programming language which
was capable of exception handling and
interfacing with the Amoeba operating
system.
iii.Python Construct
i.Function
A function in Python is a collection of
statements grouped under a name. You can
use it whenever you want to execute all those
statements at a time. You can call it wherever
you want and as many times as you want in a
program. A function may return a value.
ii.Classes
As we discussed earlier, Python is an object
-oriented language. It supports classes and
objects. A class is an abstract data type. In
other words, it is a blueprint for an object
of a certain kind. It holds no values. An
object is a real-world entity and an instance
of a class.
iii.Modules
A Python module is a collection of related
classes and functions. We have modules for
mathematical calculations, string manipul-
ations, web programming, and many more.
We will discuss Python Module in detail in a
later lesson.
iv.Packages
Python package is a collection of related
modules. You can either import a package
or create your own.
v.List
You can think of a list as a collection of values.
Declared in the CSV (Comma-Separated Values)
format and delimit using square brackets:
life = [‘love’, ‘wisdom’, ‘anxiety’];
arity = [1,2,3];
Notice that we do not declare the type for the
list either. A list may also contain elements of
different types, and the indexing begins at 0:
person = [‘firstname’, 21];
print(person[1])
Output: 21
You can also slice lists; slicing is a
way of retrieving some values from it. We will
learn more about it in further lessons.
vi.Tuple
A tuple is like a list, but it is immutable
(you cannot change its values).
pizza = (‘base’, ‘sauce’, ‘cheese’, ‘mushroom’);
pizza[3] = ‘jalapeno’
This raises a TypeError.
vii.Dictionary
A dictionary is a collection of key-value pairs.
Declare it using curly braces, and commas to
separate key-value pairs. Also, separate
values from keys using a colon (:).
student = {‘Name’: ‘Abc’, ‘Age’: 21}
print(student[‘Age’])Output: 21
viii.Comments & Docstrings
Declare comments using an octothorpe (#).
However, Python does not support multiline
comments. Also, docstrings are documentat-
ion strings that help explain the code.
#This is a comment
“““
This is a docstring
”””
Python has a lot of other constructs. These
include control structures, functions,
exceptions, etc. We will discuss these in
further tutorials.
Features of Python
The Python programming language is one
of the richest languages. In this Python
tutorial, the several features of Python:
PYTHON – A PROGRAMMING LANGUAGE
ABSTRACT:
comparison of python language with other popularly known languages. The python language has
a vast advantages in the field of web application development. This language is popularly known
for its easy to read code which makes the developer life easy. The other feature is that this
language is known for its indentation which makes the number of lines of code to reduce
drastically. Many top companies and organizations use this powerful language including Google,
IBM etc. It is also one of the top paid programming languages in the world. Python language
INTRODUCTION:
Python is processed only during the run time by the interpreter which makes this programming
language as an Interpreted programming language. This language does not require compilation
before the program has to be executed which is similar to the languages like PHP or PERL. The
python programs are interactive which means you don’t exactly have to wait till you write the
entire program. The concept of Object-Oriented will be supported by Python language which
encapsulates the code with objects. The scope of python language is very vast as it being from
simple text processing to huge web applications like google speech recognition etc. Python is
also known as the beginner level language because it is very easy to understand for the
beginners.
PYTHON SPECIFICATIONS:
Simple to-learn: Python has couple of catchphrases, straightforward structure, and a plainly
characterized language structure. This permits the understudy to get the dialect rapidly.
Simple to-peruse: Python code is all the more obviously characterized and noticeable to the eyes.
A wide standard library: Python's main part of the library is exceptionally compact and cross-
Intelligent Mode: Python has support for an intuitive mode which permits intelligent testing and
Versatile: Python can keep running on a wide assortment of equipment stages and has the same
Extendable: You can add low-level modules to the Python translator. These modules empower
GUI Programming: Python underpins GUI applications that can be made and ported to numerous
framework calls, libraries and windows frameworks, for example, Windows MFC, Macintosh,
PYTHON IDENTIFIERS:
A Python identifier is a name used to recognize a variable, capacity, class, module or other item.
An identifier begins with a letter start to finish or an underscore (_) trailed by zero or more
letters, underscores and digits (0 to 9). Python does not permit accentuation characters, for
example, @, $, and % inside of identifiers. Python is a case touchy programming dialect. In this
Class names begin with a capitalized letter. Every other identifier begin with a lowercase letter.
Beginning an identifier with a solitary driving underscore demonstrates that the identifier is
private. Beginning an identifier with two driving underscores demonstrates a firmly private
identifier. In the event that the identifier additionally closes with two trailing underscores, the
Python gives no props to show squares of code for class and capacity definitions or stream
control. Pieces of code are signified by line space, which is unbendingly authorized. The quantity
of spaces in the space is variable, however all announcements inside of the square must be
MULTI-LINE INDENTATION
Articulations in Python commonly end with another line. Python does, on the other hand, permit
the utilization of the line continuation character (\) to mean that the line ought to proceed.
BLANK LINES:
A line containing just whitespace, conceivably with a remark, is known as a clear line. In an
intelligent mediator session, you must enter a void physical line to end a multiline proclamation.
VARIABLES:
Variables are only saved memory areas to store values. Based on the information sort of a
variable, the translator dispenses memory and chooses what can be put away in the saved
memory.
VARIABLE ALLOCATION:
Python variables don't require unequivocal announcement to save memory space. The equivalent
STRINGS:
quotes. Python takes into consideration either combines of single or twofold quotes. Subsets of
strings can be taken utilizing the administrator ([ ] and [:]) with lists beginning at 0. The in
addition to (+) sign is the string link administrator and the reference bullet (*) is the redundancy
administrator.
PYTHON LISTS:
Records are the most adaptable of Python's compound information sorts. A rundown contains
things isolated by commas and encased inside of square sections ([]). The qualities put away in a
rundown can be gotten to utilizing the cut administrator ([ ] and [:]) with files beginning at 0
initially of the rundown and working their approach to end - 1. The in addition to (+) sign is the
rundown connection administrator, and the reference mark (*) is the reiteration administrator.
PYTHON TUPLES:
A tuple is another succession information sort. A tuple comprises of various qualities isolated by
commas. The principle contrasts in the middle of records and tuples are: Lists are encased in
sections ([ ]) and their components and size can be changed, while tuples are encased in
PYTHON DICTIONARY:
Python's word references are slightly hash table sort. They work like cooperative exhibits or
hashes found in Perl and comprise of key-quality sets. A lexicon key can be any Python sort,
however are typically numbers or strings. Lexicons are encased by wavy props ({ }) and
DECISION MAKING:
Choice making is foresight of conditions happening while execution of the system and indicating
moves made by conditions. Choice structures assess numerous expressions which create TRUE
or FALSE as result. Python programming dialect expect any non-zero and non-invalid qualities
as TRUE, and in the event that it is either zero or invalid, then it is accepted as FALSE value.
Python programming dialect gives taking after sorts of choice making articulations.
Python has been an item situated dialect since it existed. Due to this, making and utilizing classes
and questions are out and out simple. This part offers you some assistance with becoming a
specialist in utilizing Python's article arranged programming backing. On the off chance that you
don't have any past involvement with article arranged (OO) programming, you might need to
OOP TERMINOLOGIES:
characteristics that portray any object of the class. The properties are information individuals
(class variables and example variables) and techniques, got to by means of spot documentation.
Class variable: A variable that is shared by all occurrences of a class. Class variables are
characterized inside of a class however outside any of the class systems. Class variables are not
Information part: A class variable or occasion variable that holds information connected with a
Capacity over-burdening: The task of more than one conduct to a specific capacity. The operation
Example variable: A variable that is characterized inside a system and has a place just to the
Legacy: The exchange of the qualities of a class to different classes that are gotten from it.
article includes both information individuals (class variables and occurrence variables) and
routines.
REFERENCES:
1) Van Rossum, Guido, and Fred L. Drake. The python language reference manual. Network Theory
Ltd., 2011.
2) Dobesova, Zdena. "Programming language Python for data processing."Electrical and Control
Engineering (ICECE), 2011 International Conference on. IEEE, 2011.
3) Pedregosa, Fabian, et al. "Scikit-learn: Machine learning in Python." The Journal of Machine
Apress, 2010.
8) van Rossum, Guido, and Fred L. Drake. "The Python Language Reference: Release 2.6.
4." Python Software Foundation (2009).
Bibliography