CHPT 1
CHPT 1
CHPT 1
What is Python?
Python is a popular programming language. Python is a general-purpose interpreted, interactive,
object-oriented, and high-level programming language. It was created by Guido van Rossum during
1985- 1990 and released in 1991. Like Perl, Python source code is also available under the GNU
General Public License (GPL). It is used for Web development (server-side), software development,
mathematics, system scripting.
Python Features
Page 1 of 7
CSMSS College of Polytechnic Programming With Pyton-22616
Graphical Users 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. Extensible feature:
Python is Extensible language. We can write our some python code into c or c++ language and
also we can compile that code in c/c++ language.
8. Python is 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 platform such as Linux, Unix and Mac then we do not
need to change it, we can run this code on any platform.
9. Python is Integrated language:
Python is also an Integrated language because we can easily integrated python with other
language like c, c++ etc.
10. Interpreted Language:
When a programming language is interpreted, it means that the source code is executed line by
line, and not all at once. Programming languages such as C++ or Java are not interpreted, and
hence need to be compiled first to run them. There is no need to compile Python because it is
processed at runtime by the interpreter.
11. Large Standard Library:
Python has a large standard library which provides rich set of module and functions so you do
not have to write your own code for every single thing. There are many libraries present in
python for such as regular expressions, unit-testing, web browsers etc.
12. Robust Standard Library:
Python has an extensive standard library available for anyone to use. This means
that programmers don’t have to write their code for every single thing unlike other programming
languages. There are libraries for image manipulation, databases, unit-testing, expressions and a
lot of other functionalities. In addition to the standard library, there is also a growing collection
of thousands of components, which are all available in the Python Package Index.
13. Portable:
Python is portable in the sense that the same code can be used on different machines. Suppose
you write a Python code on a Mac. If you want to run it on Windows or Linux later, you don’t
Page 2 of 7
CSMSS College of Polytechnic Programming With Pyton-22616
have to make any changes to it. As such, there is no need to write a program multiple times for
several platforms.
14. Simplify Complex Software Development:
Python can be used to develop both desktop and web apps and complex scientific and numerical
applications. Python's data analysis features help you create custom big data solutions without so
much time and effort. You can also use the Python data visualization libraries and APIs to
present data in a more appealing way. Several advanced software developers use Python to
accomplish high-end AI and natural language processing tasks.
15. Other Advanced Programming Features
Python contains several advanced programming features such as generators (used to create
iterators with a different approach that most other languages) and list comprehensions (used to
create new lists from other iterables). Python also has automatic memory management
eliminating the need to manually allocate and free memory in the code.
16. Expressive
Python needs to use only a few lines of code to perform complex tasks. For example, to display
Hello World, you simply need to type one line - print(“Hello World”). Other languages like Java
or C would take up multiple lines to execute this.
17. Dynamically Typed Language:
Many programming languages need to declare the type of the variable before runtime. With
Python, the type of the variable can be decided during runtime. This makes Python a
dynamically typed language.
For example, if you have to assign an integer value 20 to a variable “x”, you don’t need to write
int x = 20. You just have to write x = 15.
Page 3 of 7
CSMSS College of Polytechnic Programming With Pyton-22616
7. ABC programming language is said to be the predecessor of Python language which was capable
of Exception Handling and interfacing with Amoeba Operating System.
8. Python is influenced by following programming languages:
i. ABC language.
ii. Modula-3
Python programming language is being updated regularly with new features and supports. There are lots
of updations in python versions, started from 1994 to current release.
Python Applications
Python is known for its general purpose nature that makes it applicable in almost each domain of
software development. Python as a whole can be used in any sphere of development.
Here, we are specifing applications areas where python can be applied.
1) Web Applications
Page 4 of 7
CSMSS College of Polytechnic Programming With Pyton-22616
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. It also
provides Frameworks such as Django, Pyramid, Flask etc to design and delelop web based
applications. Some important developments are: PythonWikiEngines, Pocoo, PythonBlogSoftware
etc.
2) Desktop GUI Applications
Python provides Tk GUI library to develop user interface in python based application. Some other
useful toolkits wxWidgets, Kivy, pyqt that are useable on several platforms. The Kivy is popular for
writing multitouch applications.
3) Software Development
Python is helpful for software development process. It works as a support language and can be used
for build control and management, testing etc.
4) Scientific and Numeric
Python is popular and widely used in scientific and numeric computing. Some useful library and
package are SciPy, Pandas, IPython etc. SciPy is group of packages of engineering, science and
mathematics.
5) Business Applications
Python is used to build Bussiness applications like ERP and e-commerce systems. Tryton is a high
level application platform.
6) Console Based Application
We can use Python to develop console based applications. For example: IPython.
7) Audio or Video based Applications
Python is awesome to perform multiple tasks and can be used to develop multimedia applications.
Some of real applications are: TimPlayer, cplay etc.
8) 3D CAD Applications
To create CAD application Fandango is a real application which provides full features of CAD.
9) Enterprise Applications
Python can be used to create applications which can be used within an Enterprise or an Organization.
Some real time applications are: OpenErp, Tryton, Picalo etc.
10) Applications for Images
Using Python several application can be developed for image. Applications developed are: VPython,
Gogh, imgSeek etc.
Page 5 of 7
CSMSS College of Polytechnic Programming With Pyton-22616
Python Identifier is the name we give to identify a variable, function, class, module or other object. That
means whenever we want to give an entity a name, that’s called identifier. Sometimes variable and
identifier are often misunderstood as same but they are not.
o The first character of the variable must be an alphabet or underscore ( _ ).
o All the characters except the first character may be an alphabet of lower-case (a-z), upper-case
(A-Z), underscore or digit (0-9).
o Identifier name must not contain any white-space, or special character (!, @, #, %, ^, &, *).
o Identifier name must not be similar to any keyword defined in the language.
o Identifier names are case sensitive for example myname, and MyName is not the same.
o Examples of valid identifiers: a123, _n, n_9, etc.
o Examples of invalid identifiers: 1a, n%4, n 9, etc.
Though these are hard rules for writing identifiers, also there are some naming conventions which are
not mandatory but rather good practices to follow.
o Class names start with an uppercase letter. All other identifiers start with a lowercase letter.
o Starting an identifier with a single leading underscore indicates the identifier is private.
o If the identifier starts and ends with two underscores, than means the identifier is language-
defined special name.
o While c = 10 is valid, writing count = 10 would make more sense and it would be easier to
figure out what it does even when you look at your code after a long time.
o Multiple words can be separated using an underscore, for example this_is_a_variable.
Variables:
A variable, as the name indicates is something whose value is changeable over time. In fact a
variable is a memory location where a value can be stored. Later we can retrieve the value to use.
But for doing it we need to give a nickname to that memory location so that we can refer to it. That’s
identifier, the nickname.
Python does not bound us to declare variable before using in the application. It allows us to create
variable at required time. We don't need to declare explicitly variable in Python. When we assign
any value to the variable that variable is declared automatically.
The equal (=) operator is used to assign value to a variable. The operand to the left of the = operator
is the name of the variable and the operand to the right of the = operator is the value stored in the
variable
Page 6 of 7
CSMSS College of Polytechnic Programming With Pyton-22616
Multiple Assignment
Python allows us to assign a value to multiple variables in a single statement which is also known as
multiple assignment.
1. Assigning single value to multiple variables
x=y=z=50
2. Assigning multiple values to multiple variables:
a,b,c = 1,2,"john"
Python Keywords
Python Keywords are special reserved words which convey a special meaning to the
compiler/interpreter. Each keyword has a special meaning and a specific operation. These keywords
can't be used as variable. Following is the List of Python Keywords.
False def if raise None Del Import return True elif in try
and else is while as excep lambda with assert finally nonlocal yield
t
break for not class from or continue global pass
Page 7 of 7