python

10

Click here to load reader

Upload: amgad-muhammad

Post on 19-May-2015

310 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Python

Introduction to Python

Prepared by:

Amgad Mohamed | Hussein Mohamed | Yasser Mohsen

“To describe something as clever is NOT considered a compliment in the Python culture.” Alex Martelli, Python Cookbook (2nd ed., p. 230)

Page 2: Python

I. Brief Introduction

II. Quick History

III. Advantages & Disadvantages

IV. Benchmarking

V. Translation

VI. Code Sample

VII. Easter Egg

VIII.References

Page 3: Python

Brief Introduction

– Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability.

– Python claims to "combine remarkable power with very clear syntax", along with a huge standard library with the uniqueness of using indentation as a block delimiters.

– Python had three major releases to support multiple programming paradigms including Object Oriented Programming, Imperative programming and Functional programming. Additionally, it features a fully dynamic typing systems and automatic garbage collection.

Page 4: Python

Quick History

– Python was conceived in the late 1980s, and its implementation was started in December 1989 by Guido van Rossum.

– Python 2.0 was released on 16 October 2000, with many major new features including a full garbage collector and support for Unicode.

– Python 3.0 (also known as Python 3000 or py3k), a major, backwards-incompatible release, was released on 3 December 2008.

• Python 3.0 was developed with the same philosophy as in prior versions. However, as Python had accumulated new and redundant ways to program the same task, Python 3.0 had an emphasis on removing duplicative constructs and modules, in keeping with "There should be one and preferably only one obvious way to do it".

Page 5: Python

Advantages / DisadvantagesI. Supports multiple paradigms.

II. Less code To Achieve More (Expressiveness)

III. Support Libraries (Extendibility)

IV. High productivity

A. Less time to code and since there is no compilation step; the edit-test-

debug cycle is incredibly fast.

B. Anecdotal evidence suggests that one Python programmer can finish in

two months what two C++ programmers can't complete in a year,

Python code is often 5-10 times shorter than equivalent C++ code.

C. Python programs are typically 3-5 times shorter than equivalent Java

programs.

V. Auto Memory Management and Exception Handling.

I. Compared to other programming languages, Python performance (time and space), is way behind, Hard to Translate, and lack of documentation.

Page 6: Python

Benchmarking

Page 7: Python

Translation

– Python Code is compiled to byte code similar to Java, and then this Byte code is interpreted to the underlying machine language. (Pseudo Interpreter)

– This byte code provides • portability.• speed execution - byte code can be run much

more quickly than the original source code

Page 8: Python

Sample Code - GCD

def gcd(a, b):

"greatest common divisor"

while a != 0:

a, b = b%a, a # parallel assignment

return b

Page 9: Python

Zen of Python (Easter Egg)• Beautiful is better than ugly.• Explicit is better than implicit.• Simple is better than complex.• Complex is better than complicated.• Flat is better than nested.• Sparse is better than dense.• Readability counts.• Special cases aren't special enough to break the rules.• Although practicality beats purity.• Errors should never pass silently• Unless explicitly silenced.• In the face of ambiguity, refuse the temptation to guess.• There should be one-- and preferably only one --obvious way to do it.• Although that way may not be obvious at first unless you're Dutch.• Now is better than never.• Although never is often better than *right* now.• If the implementation is hard to explain, it's a bad idea.• If the implementation is easy to explain, it may be a good idea.• Namespaces are one honking great idea -- let's do more of those!

Page 10: Python

References

• [1] http://docs.python.org/faq/general.html#what-is-python-good-for. Retrieved 2011-10-04

• [2] http://www.python.org/doc/essays/blurb/ Python documentation. Retrieved 2011-10-04.

• [3] http://docs.python.org/faq/general#what-is-python Retrieved 2011-10-04

• [4] http://www.artima.com/intv/pythonP.html Retrieved 2011-10-04• [5] http://docs.python.org/license.html Retrieved 2011-10-04• [6] http://python.org/download/releases/3.0/ Retrieved 2011-10-04• [7]http

://ugweb.cs.ualberta.ca/~c410/F07/410/presentations/ReportPython.pdf• [8] Learning Python 4th Ed, Mark Lutz• [9] Core Python Programming 2nd Edition, Wesley J. Chun - Sep 2006• [10] Python Enhancement Proposals, 20 -- The Zen of Python.