Presentation is loading. Please wait.

Presentation is loading. Please wait.

Python Joseph Eckstrom, Benjamin Moore, Willis Kornegay.

Similar presentations


Presentation on theme: "Python Joseph Eckstrom, Benjamin Moore, Willis Kornegay."— Presentation transcript:

1 Python Joseph Eckstrom, Benjamin Moore, Willis Kornegay

2 Overview Written to improve programmer productivity Python gives programmers the option to use object- oriented, structured or functional programming paradigms. Trades some speed for productivity In era of fast machines, acceptable

3 History Written at CWI, Netherlands, by Guido van Rossum Named BDFL, or “Benevolent Dictator for Life” by Python community Based on ABC, but ABC had drawbacks Monolithic design not adaptable Could not access file system or O.S.

4 Evolution Python 1.0 Classes, inheritance, functional programming Python 2.0 Garbage collection, list comprehensions, Haskell-like syntax Python 3.0 Refinement of existing features, overhauls to standard libraries

5 Language Concepts High level, interpreted language Supports multiple paradigms OO, Imperative, Functional No semicolons at the end of lines Blocks represented by indentations

6 Examples of Use – Lambda Functions >>> def make_incrementor (n): return lambda x: x + n... >>> f = make_incrementor(2) >>> g = make_incrementor(6) >>> print(f(42), g(42)) 44 48 >>> print(make_incrementor(22)(23)) 45

7 Examples of Use – Lists >>> S = [x**2 for x in range(10)] >>> V = [2**i for i in range(13)] >>> M = [x for x in S if x % 2 ==0] >>> print(S); print(V); print(M) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096] [0, 4, 16, 36, 64]

8 Examples of Use – Classes >>> class MyClass:...# A simple example class …i = 12345 …def f(self): …return “Hello, world.” … >>> x = Myclass() >>> x.f() Hello, world.

9 Comparison - Ruby Both imperative/functional, object oriented, & interpreted Python emphasizes a single best way, and features extensive standard libraries Ruby emphasizes elegant syntax & greater object-orientation

10 Comparison – C++ Both object-oriented, imperative languages C++ compiled to hardware native code; Python compiled to bytecode, executed by VM Both languages are flexible in terms of object- orientation.


Download ppt "Python Joseph Eckstrom, Benjamin Moore, Willis Kornegay."

Similar presentations


Ads by Google