1. Play with Python
Orientation Session
كل الكتب والمراجع و البرامج موجودة على أجهزة معامل الكلية :ملحوظة
/www.python.org
2. Agenda
• Why?
• Interpreted vs Compiled languages
• Dynamically typed vs Static typed languages
• A Quick Tour of Python
• Course Structure
• Environment and Software
Guido van
Rossum
3. Why?
Easy, Productive, Extensible
Youtube: :"Python is fast enough for our site and allows us to
produce maintainable features in record times, with a minimum of
developers"
"NASA code policy is to implement everything in Python, and leave
performance critical pieces of code to C++"
Peter Norvig (AI Computer Scientist, Director of Search Quality at
Google, recommends Python for his AI Class): "Today dozens of
Google engineers use Python, and we're looking for more people
with skills in this language."
4. Why?
Easy, Productive, Extensible
EVE Online : "Python enabled us to create EVE Online, a massive multiplayer
game, in record time. The EVE Online server cluster runs over 50,000
simultaneous players in a shared space simulation, most of which is created in
Python"
stackoverflow.com user: “If you are a programmer charging by the hour,
you SHOULD NOT use Python, because it ensures you won't be able to
charge your customer much”
Mark Lutz (Python Books Author): "Today, I can safely say that Python
has changed my life. I have moved to a different continent."
5. Why?
Who uses Python ?:
Watch this Google I/O video clip, Wesley
Chun listing the uses of python and what
companies use Python. (from 22:35 to 29:10 )
6. Why?
Who uses Python ?:
Google
NASA
Yahoo
Youtube Watch this Google I/O video clip, Wesley
Chun listing the uses of python and what
Linux (RedHat, Ubuntu, ...) companies use Python. (from 22:35 to 29:10 )
Lots of researchers
EVE online (Thousands of online players)
MIT (Programming Intro. Course)
etc...
7. Awards !
Why?
Who uses Python ?:
Google
NASA
Yahoo
Youtube Watch this Google I/O video clip, Wesley
Chun listing the uses of python and what
Linux (RedHat, Ubuntu, ...) companies use Python. (from 22:35 to 29:10 )
Lots of researchers
EVE online (Thousands of online players)
MIT (Programming Intro. Course)
etc...
8. Awards !
Why?
Who uses Python ?:
Google
NASA
Yahoo
Youtube
is Open Source, free,
even for commercial use !
Watch this Google I/O video clip, Wesley
Chun listing the uses of python and what
Linux (RedHat, Ubuntu, ...) companies use Python. (from 22:35 to 29:10 )
Lots of researchers
EVE online (Thousands of online players)
MIT (Programming Intro. Course)
etc...
9. Why?
Python Software Foundation (PSF), the organization that is devoted to advance
python, has these prestigious members
(and many other companies and organizations ....)
10. Why?
Python is mainly used in:
• Rapid Prototyping and Experimenting
• Scripting
• Text Processing
• Web applications
• Game Development
• System Administrations
• Fun Stuff that need quick experiments:
o like robotics or any scientific math
• Teaching kids programming :)
11. Interpreted vs Compiled languages
• Python, Javascript and many other languages are
"Interpreted" languages
o which means there is no compilation phase needed to run the
program
o instead an interpreter interprets your code directly and
executes it
o this means that you don't have to wait for long compilation
times in big projects
• But the down side that is the language is slower
than compiled ones like C/C++/C#/Java
o Often, productivity and development time is much important
than language speed
o in some cases you may need special extra speed, here you
can implement the time critical pieces in a C++ for example
12. Interpreted vs Compiled languages
• The python interpreter (Demo)
o one of the great advantages of any interpreted language, the
interpreter allows you to instantly execute any piece of code
you need to understand or test
13. Interpreted vs Compiled languages
• This allows you to do quick experiments and prototypes for your ideas like
simple programs or even scientific functions (like matlab, maple, octane ...
but with much stronger and easier OOP language)
14. Interpreted vs Compiled languages
• This allows you to do quick experiments and prototypes for your ideas like
simple programs or even scientific functions (like matlab, maple, octane ...
but with much stronger and easier OOP language)
15. This Makes Python Fun !
BUT, Python is not a replacement to other languages:
A common error some people do, is they tend to put
languages in struggle as if there must be only 1
language to learn
THIS is WRONG!
Python/Javascript/Lisp are great, C++/C#/Java are great,
every language has its role in this world.
You can be a Pythonista and a C++er in the same time
And you can always mix them together to fit your needs
16. Dynamically typed vs Static typed
languages
• In Java, C#, C/C++, types are explicit:
• int n = 7;
• String s = “Hi”;
• var n = 3;
• in Python, Ruby, Javascript, types are dynamic:
• n=7
• s = “Hi”
• n = "hello"
No Static Types
17. A Quick Tour
A Sample Program:
def greetings(name):
if name == "": #This is a comment
msg = "Hello Guest. Welcome!"
else:
msg = "Hello " + name + ". Welcome!"
return msg
====================================
>>> greetings("FCIS")
‘Hello FCIS. Welcome!’
>>> greetings("")
‘Hello FCIS. Welcome!’
18. A Quick Tour
A Sample Program:
Function
def greetings(name):
if name == "": #This is a comment
msg = "Hello Guest. Welcome!"
Indentation else:
msg = "Hello " + name + ". Welcome!"
return msg Variable
====================================
>>> greetings("FCIS")
‘Hello FCIS. Welcome!’
>>> greetings("")
‘Hello FCIS. Welcome!’
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31. Other Python Aspects
• Generators
• Map, Zip
• Lambdas
• List comprehensions
• Closures
• ...
32. Course Structure
• Lecture 1, 2:
• Python Language, Object Oriented
• Lecture 1: Strings, Numbers, Loops, Functions, List, Tuple,
Dictionary
• Lecture 2: , importing packages, Sets, Sorting, Classes, Object
Oriented, Constructors, Destructors, isinstance
• Lecture 3, 4:
• Exceptions
• More Language Features (Map, Zip, Lambdas, Generators)
• Saving and restoring from files
• GUI with PyQt4
• Diverse uses of Python: scientific computing with python,
graphs, visualizations
• Lecture 5, 6:
• Web with Django
• Game with PyGame
33. Environment and Software
• Python language (The Python language)
• Version 2.7.3 http://www.python.org/download/
• Aptana Studio 3 (our main IDE) :
• http://www.aptana.com/products/studio3/download (needs java)
• Pythonxy (Scientific Computing):
• http://code.google.com/p/pythonxy/
• PyGame (Games):
• http://www.pygame.org/download.shtml
• Django (Web):
• https://www.djangoproject.com/download/
• All Free !
(Note: PySide is deleted, we don't' need it, we will work with PyQt4 which is
already included in Pythonxy)
Note: If you want to use Python in visual studio 2010 and don't want
to download big downloads like Aptana, you can use Microsoft Official
"Python Tools for visual studio" at http://pytools.codeplex.com/,
only 4 MB beside python, and you have an excellent full IDE for
python.
34. References ()الترتيب حسب األهمية
This Presentation References:
• The Official The Python Tutorial: http://docs.python.org/tutorial/
• Official Python Library Reference: http://docs.python.org/library/
• Official Python Language Reference: http://docs.python.org/reference/
• Pyschools Python Intro: http://www.pyschools.com/downloads/A_Quick_Python_Tour.pdf
35. References ()الترتيب حسب األهمية
General References for the Course:
• Beginners:
o Concentrated short introductions for the language (directly only to the language and
examples, no other talk about anything else except the language, any one of the following is
good):
The Official The Python Tutorial (link in previous slide)
A byte of Python, for Python 2.x (A Quick Book): http://www.swaroopch.org/notes/Python
PySchools Python Quick Reference Guide (along with online interactive excercises to solve,
very useful): http://doc.pyschools.com/html/index.html, Exercises:
http://www.pyschools.com/quiz/view_summary
o Online Interactive Tutorials (interactive exercising during reading, very enjoyable)
University of Waterloo online Interactive Python Tutorial: http://cscircles.cemc.uwaterloo.ca/using-
this-website/
Online Python Tutor (just excercises, I but it here shows automatic code tracing while exercising):
http://people.csail.mit.edu/pgbovine/python/tutor.html#mode=edit
learnpython.org's interactive Python tutorial: http://www.learnpython.org/
o Beginners Books (not only language and examples, but everything you need to know about
Python) (*):
Python for Dummies (2006) (Fast short examples like "A byte of Python")
Core Python Programming (2nd Edition) , Chun (2006) (longer examples and explanation)
Learning Python, Mark Lutz (4th Edition) (For the very detailed explanation of everything about
Python, very good if you have time, or want to parachute on specific thing to understand deeply)
(*) https://docs.google.com/file/d/0B2Jt9cH9yJtraE1iOGR0X19zNFk/edit