Presentation is loading. Please wait.

Presentation is loading. Please wait.

‘And Now For Something Completely Different’ Python Programming David Hartwell Clements.

Similar presentations


Presentation on theme: "‘And Now For Something Completely Different’ Python Programming David Hartwell Clements."— Presentation transcript:

1 ‘And Now For Something Completely Different’ Python Programming David Hartwell Clements

2 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 2 History of the Snake c. 1990 Guido van Rossum created Python as a descendant to ABC that would appeal to UNIX/C hackers. Named after Monty Python’s Flying Circus. Python “bridges the gap” between system and scripting languages.

3 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 3 Languages/Paradigms Studied in MACS400 Prolog –Logical C/C++ –Iterative Java – Object Oriented LISP (Lots of Insanely Stupid Parentheses) –Functional

4 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 4 So What is Python? “Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.” Python is flexible, powerful, and extremely easy to use. Python is 100% Open Source. Python has elements of Functional, Iterative, and Object Oriented Paradigms.

5 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 5 Advantages Short Code –3 to 5 times shorter than Java! –5 to 10 times shorter than C++! Extensible using C ‘Executable Pseudocode’ Rapid Prototyping Heavily Cross-Platform (Un*x, MacOS, &c.) Object Oriented

6 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 6 Object Orientation, “Done Right” Full, Non-Mandated, Support Classes Inheritance and Multiple Inheritance Virtual Methods (pure and otherwise) Operator Overloading

7 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 7 An Iterative Example answer = ‘’ //default it out while answer != “yellow”: name = raw_input(“What is your name? ”) quest = raw_input(“What is your quest? ”) answer = raw_input(“What is your favorite color? ”) if answer != “yellow”: print “Auuuuuuuuugh” print “Right. Off you go.”

8 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 8 A Functional Example import shrubbery #This is how we include def function1(x,y): return x * y function2 = lambda x, y: x + y #in-line comments print apply( function1, (3, 5) ) for y in map( function2, (2,3,5), (7,11,13) ): print y

9 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 9 An Object Oriented Example class Snake: … class Python( Snake ): def __add__( self, other ): self.hunt( other ) … def hunt( target ): … MyPython, MyAsp = Python(), Snake()

10 6 December 2000Copyright © 2000 David Hartwell Clements, See Notes for Details 10 Getting More Information Any O’Reilly (Animal) book, particularly Programming Python (python on the cover) and Learning Python (rat on the cover). http://www.python.org


Download ppt "‘And Now For Something Completely Different’ Python Programming David Hartwell Clements."

Similar presentations


Ads by Google