O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Introduction to Python Programing

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
Python Programming
Python Programming
Carregando em…3
×

Confira estes a seguir

1 de 15 Anúncio
Anúncio

Mais Conteúdo rRelacionado

Diapositivos para si (20)

Semelhante a Introduction to Python Programing (20)

Anúncio

Mais recentes (20)

Introduction to Python Programing

  1. 1. PYTHON PROGRAMING SAMEER PATIL
  2. 2. INTRODUCTION • C programing concern with functional aspect. We are concerning with writing code using function. • Programing will become easy if it based on real life example, hence they develop Object Oriented Language like Java and .NET where programing 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))
  3. 3. HISTORY • 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.
  4. 4. FEATURES OF PYTHON • Simple • Easy to learn • Open Source • High level Language • Dynamically Typed • Platform Independence • Portable • procedure and Object oriented
  5. 5. • 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']
  6. 6. • But what ‘types’ are these variables? Let’s use the types module to find out: • >>> from types import * • >>> type(year) • <type 'int'> • >>> type(dec) • <type 'float'> • >>> type(hello) • <type 'str'> • >>> type(alphabet) • <type 'list'>
  7. 7. • 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.
  8. 8. • Class is collection of objects having similar attributes and operation. • Python Packages – • BOTO 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-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.
  9. 9. 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
  10. 10. C VS PYTHON C programing 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 Deallocation done by PVM Procedural approch Oops based
  11. 11. JAVA VS PYTHON JAVA PYTHON Memory allocation and deallocation 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 programing used in java 8.0 in lamda expression Oops language, blends functional programming with lambda expression inbuild.
  12. 12. 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.
  13. 13. 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
  14. 14. MEMORY MANAGEMENT IN PYTHON • Python , memory allocation and deallocation 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.
  15. 15. GARBAGE COLLECTION IN PYTHON • Python’s memory allocation and deallocation 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 deallocated.

×