Introduction to
Python and installation:
Python is a widely used general-purpose, high level
programming language.
It was first introduced in 1991 by Guido van Rossum , a
Dutch computer programmer.
• The language places strong emphasis on code reliability
and simplicity so that the programmers can develop applications rapidly
developed by Python Software Foundation.
It was mainly developed for emphasis on code readability,
and its syntax allows programmers to express concepts in fewer lines of code.
Python is a programming language that lets you work quickly
and integrate systems more efficiently.
Beginning with Python
programming:
1)
Finding an Interpreter: Before we start Python
programming, we need to have an interpreter to interpret and run our programs.
There are certain online interpreters like https://ide.geeksforgeeks.org/,
http://ideone.com/ or http://codepad.org/ that can be used to start Python
without installing an interpreter.
2)
Windows: There are many interpreters available
freely to run Python scripts like IDLE (Integrated Development Environment)
which is installed when you install the python software.
Why to use Python: The
following are the primary factors to use python in day-to-day life
1. Python is
object-oriented
Structure supports such concepts as polymorphism, operation
overloading and multiple inheritance.
2. Indentation : Indentation
is one of the greatest feature in python
3. It’s free
:(open source): Downloading python and installing python is free and easy
4. It’s Powerful
Ø
Dynamic typing
Ø
Built-in types and
tools
Ø
Library utilities
Ø
Third party
utilities (e.g. Numeric, NumPy, sciPy)
Ø
Automatic memory
management
5. It’s Portable
Ø
Python runs
virtually every major platform used today
Ø
As long as you have
a compatible python interpreter installed, python
programs will run in exactly the same manner, irrespective
of platform.
6. It’s easy to use
and learn
Ø
No intermediate
compile
Ø
Python Programs
are compiled automatically to an intermediate form called
Ø
byte code, which the interpreter then reads.
Ø
This gives python
the development speed of an interpreter without the
performance loss inherent in purely interpreted languages.
Ø
Structure and
syntax are pretty intuitive and easy to grasp.
7. Interpreted
Language
Python is processed at runtime by python Interpreter
8. Interactive
Programming Language
Users can interact with the python interpreter directly for
writing the programs
9. Straight forward
syntax
The formation of python syntax is simple and straight forward
which also makes it
popular.
Python is a general purpose interpreted interactive object
oriented and high level programming language.
Python is multi-paradigm programming language ,which allows
user to code in several different programming styles.
Python supports cross platform development and is available
through open source.
Python is widely used
for scripting in Game menu applications effectively.
Python can be easily integrated with C/C++ CORBA, ActiveX
and Java.
CPython is a python integrated with C/C++ language.
Similarly JPython is a purely integrated language where Java
and Python code can interchangeably use inline in the program.
Working with Python :Python
Code Execution:
Python’s traditional runtime execution model: Source code
you type is translated to byte
code, which is then run by the Python Virtual Machine (PVM).
Your code is
automatically compiled,
but then it is interpreted.
Source Byte code Runtime
Source code extension is .py
Byte code extension is .pyc
(Compiled python code)
There are two modes
for using the Python interpreter:
• Interactive Mode
• Script Mode
m.py
m.pyc
Running Python in interactive mode:
Without passing python script file to the interpreter,
directly execute code to Python prompt.
Once you’re inside the python interpreter, then you can
start.
>>> print("hello world")
hello world
Python can be easily
integrated with C/C++ CORBA, ActiveX and Java.
• CPython is a python integrated with C/C++ language.
• Similarly JPython is a purely integrated language where
Java and Python code can interchangeably use inline in the program.
Advantages of Python
• Most programs in Python require considerably less number
of lines of code to perform the same task compared to other languages like C
.So less programming errors and reduces the development time needed also.
• Though Perl is a powerful language ,it is highly syntax
oriented .Similarly C also.
Why to Learn Python
• There are large number of high-level programming languages
like C ,C++,Java etc.But when compared to all these languages Python has
simplest Syntax, availability of libraries and built-in modules.
• Python comes with an extensive collection of third party
resources that extend the capabilities of the language.
Python can be used for large variety of tasks like Desktop
applications ,Data base applications, network programming ,game programming and
even mobile development also.
• Python is also a cross platform language which means that
the code written for one operating system like Windows ,will work equally well
with Linux or MacOS without any changes to the python code.
INSTALLING PYTHON ON
YOUR PC
• To learn this language first ,you have to download the
software which is the Python Interpreter.
• Presently the version in use is Python 3.x But you can
also use Python 2.x ,like 2.7..etc .This depends on your system and your
interest. To download the Python interpreter go to the site
http://www.python.org/downloads and click on the suitable icon.
The website appears as shown below.
From the website you can download the suitable version based
on
• your OS
(whether the OS is Windows , MacOS or
Linux).
• And the Processor 32 bit or 64 bit.
• For ex: if you
are using 64-bit Windows system ,you are likely to download Windowsx86-64MSI
Installer.
• So just click on the link and download and install the
Python Interpreter.
This Python shell allows us to use Python in interactive
mode.
• The shell waits for a command from the user ,executes it
and returns the result.