INTRODUCTION:
Like Other Programming Languages like C programming, It is concern with functional aspect.
We are concerning with writing code using function.
Programming will become easy if it based on real life example, hence they develop Object Oriented Language like Java and .NET where programming done with Classes and Objects.
Java Program to Write sum of two numbers
C program to write sum of two numbers • Python style • a=b=10 • print(“sum”,(a+b))
HISTORY of PYTHON:-
Python was developed by Guido Van Rossum in year 1991, at center for mathematics and Computer science managed by Dutch Govt. Developer was working on project to develop system utilities in C where he had interact with bourn shell available in UNIX. Python name appeared from the TV Show Monty Python’s Flying Circus Official launched on 20th Feb 1991. Python is Open Source.
FEATURES OF PYTHON:- Simple Easy to learn Open Source High level Language Dynamically Typed Platform Independence Portable procedure and Object oriented
Simple-Python is simple programing Language .felt like reading English sentences. It means more clarity and less stress on understating of syntax of language
Easy to learn– uses very few keyword , program structure is simple. Similar to C programing . Hence Migration from C to Python is easy for programmers.
Open Source - easily available for download www.python.org
High level Language – Similar to English Language , low level language Machine understandable code.
Dynamically Typed-in - Python , we are not declaring anything. an assignment statement binds a name to an objects can be of any type. If a name is assigned to an objects of one type, it may be later be assigned to an objects of different type.
>>>year = 2017 >>> dec = 1.1 >>> hello = 'Hello, World!' >>> alphabet = ['a','b','c']
As you can see, I didn’t have to tell Python what ‘type’ each variable value was, it assigned the types dynamically Platform Independent- Portable Procedure and OOPS based.
Class is collection of objects having similar attributes and operation.
Python Packages: –
Boto: It is amazon web services CherryPy is Object oriented HTTP framework Fiona reads and write big data files. Mysql-connector –python is driver written in python to connect to MySQL database
Numpy- It is a package for processing array of single or multidimensional type Pandas is package for powerful data structure for data analysis, time series and statistics Pillow is python imaging library.
Pyquery- represent jquery like library for python. W3lib is library of web related function.
EXECUTION OF PYTHON PROGRAM:- Python program can write in abc.py where abc is name of the program wheras .py is extension name. Compile the program into python compiler. Byte code. Abc.pyc Pvm machinecode result
C VS PYTHON: Python Programing C program execute Faster Slower compared to C Type Declaration Compulsory Not required C language type discipline in static and weak Python type discipline is dynamic and Strong Pointers available No Pointers C ha s switch statements No switch statement Memory allocation using malloc and calloc Memory allocation and De-allocation done by PVM Procedural approach Oops based.
JAVA VS PYTHON JAVA PYTHON: Memory allocation and de-allocation done by JVM PVM Switch is allowed No switch A semicolon is used to terminate the statement and comma is used to separate expression. New line indicate end of statement and semicolon is used as an expression separator Array index is positive integer Can be positive or negative. Static and weak Dynamic and strong Oops languages, functional programming used in java 8.0 in lamda expression Oops language, blends functional programming with lambda expression inbuild.
PVM:- Python source file converted in Byte Code format.
Byte code represent the fixed set of instruction created by python developers representing all types of operations. And store that file in .pyc extension
Role of PVM to convert that byte code into machine understandable code, so that computer can execute that machine code and display result. To carry out this conversion , byte code into machine code and sends that machine code to computer processor for execution. Since Interpreter plays main role, often pvm also mention as interpreter.
FROZEN BINARIES:- Frozen binary executables are packages that combine your program's byte code and the Python interpreter into a single executable program. With these, programs can be launched in the same ways that you would launch any other executable program (icon clicks, command lines, etc.). py2exe
MEMORY MANAGEMENT IN PYTHON:- Python , memory allocation and de-allocation are done during runtime automatically. The programmer need not allocate memory while creating objects or deallocate memory when deleting the objects. Python PVM take care of such issues. Everything is consider as an objects in Python. Example Strings are objects, list are objects , functions are objects. For every object, memory should be allocated .memory manager inside PVM allocates memory required for the objects created in Python Programming . All these objects are stored on separate memory called Heap. Heap is memory which allocated during runtime.
GARBAGE COLLECTION IN PYTHON:- Python’s memory allocation and de-allocation method is automatic. Python uses two strategies for memory allocation: Reference counting Garbage collection the Python interpreter only used reference counting for memory management. Reference counting works by counting the number of times an object is referenced by other objects in the system. When references to an object are removed, the reference count for an object is decremented. When the reference count becomes zero, the object is de-allocated.
No comments:
Post a Comment