150 likes | 166 Views
Python. Jordan Miller and Lauren Winkleman CS 311 Fall 2011. Guido Van Rossum implemented/created Python in 1991. He wanted to create a language anyone can use. The point was to make it an easy language to learn. Rossum is known as Python’s Principal Author
E N D
Python Jordan Miller and Lauren WinklemanCS 311Fall 2011
Guido Van Rossum implemented/created Python in 1991. He wanted to create a language anyone can use. The point was to make it an easy language to learn. • Rossum is known as Python’s Principal Author • Python was awarded the TIOBE Programming Language of the Year twice (2007, 2010) Background
‘Pythonistas’ (advocates of Python) believe that Python is better than C or C++ and should be used for all programming work, not just scripting • Uses dynamic typing with the feature of “late binding” • Uses reference counting and a cycle detecting garbage collector • Can be used as an extension language for existing modules and applications that need a programmable interface • Used on windows macintosh and unix platforms About Python
Often used as a scripting language for web applications although this was not its original purpose • Has been used in Artificial Intelligence (AI) • Can be used for CGI • Python was implemented in C • Implementations can compile not only byte codes but can turn Python code into machine code Domain and Implementation
Python’s Philosophy: “There should be one and preferably only one way to do it.” • Clean and clutter free syntax and in plain English • Multi-paradigm programming language so programmers can use different programming styles when writing (functional, object-oriented, imperative) • There are no semicolons at the end of Python source code statements. A new line means a new statement. If you need a very long line, you can use the backslash character for continuation, e.g. x = y + \z Evaluation: Writability
Python’s Goal: “To reduce confusion by having a syntax that is understandable in plain English” • Includes basic text manipulation facilities of Awk and Perl, making it easier to read • Fewer syntax rules • Similar format for if/for/while statements as other programs • A+ for readability. This is considered one of its greatest advantages. Evaluation: Readability
Python is implemented in C and relies on well understood, portable C libraries • Python.org states that in applications that started out as pure C++ with Python being added as an extension language, a higher % of code written in Python = an increase in overall performance, functionality and reliability of the application. • Creates robust applications Evaluation: Reliability
Cost of interactivity is high but it speeds up the execution time • Because it is so easy to learn and write, the cost is lower in the training and development stages and interactive mode makes testing fast and easy. “When in doubt, try it out!” Evaluation:Cost
Easy to learn, even non experienced programmers can use it. Ex: spacing and tabbing instead of extra syntax (Don’t have to learn new rules) • Can be used extensively to benefit other programming languages • Interactive mode • Development process proceeds 5 to 10 times faster than in other languages such as Java or C++ • Less memory used because a single container hold multiple data types and each type doesn’t require its own function Advantages
Python interprets the code during runtime instead of compile time causing a slower execution. Runs 1 to 5 times slower than Java or C++ • Official documentation is scarce because the language evolves so often. • New modules are not always a part of the standard release or standard library and must be imported into the project. Disadvantages
Interactive mode allows Python to function as a quick calculator. Ex:What is 5% above 88.88?% python>>> 1.05*88.8893.323999999999998 Fun Fact
If statement: if x < 3:print “hello” • For statement: for i in range(10): print i • While statement: while x < 8: x = x + 1 Syntax Statements
name = raw_input(‘Please enter your \ name:’) course = raw_input(‘Enter the course \ number:’) num = int(course) if num == 311: print name, “ is in this class.” else: print name, “ is not in this class.” Program Example
Google • Gaming industries • Battlefield 2 – score keeping and team balancing • Star Trek Bridge Commander – mission scripting and many other features • Yahoo Maps • Linux Weekly News Who’s Using Python?
A Quick, Painless Tutorial on the Python Language by Norman Matloff • python.org and wiki.python.org • ugweb.cs.ualberta.ca Sources