Introduction to Python

  • 2,858 views
Uploaded on

 

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,858
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
176
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Python Session 1: introduction to Python José Dapena Paz <jdapena@igalia.com>
  • 2. Sessions ● Session 1: – Presentation of language, brief history and practical examples of language structures. ● Session 2: – Important projects – Standard libraries – Other modules
  • 3. First session contents ● ¿What's Python? – Brief history – Properties – Documentation ¿Where? ● Introduction to the language – Installation and usage – Practical examples
  • 4. ¿What's Python? ● ¿What's Python? – Brief history – Properties – Documentation ¿Where? ● Introduction to the language – Installation and usage – Practical examples
  • 5. ¿What's Python? ● High level language ● Author: Guido Van Rossum (first release in 1991) ● Emphasis on readability. ● Priority: easy for programmer, then, computer. ● Minimalist language. Wide libraries.
  • 6. History ● Author: Guido Van Rossum. CWI. ● Begins Python at the end of 80's. Inspired in ABC language. ● First release in 1991. ● Guido Van Rossum: Benevolent Dictator For Life
  • 7. Cronology ● 1991: 1st release. Classes, inheritance, exceptions, modules and basic types list, dict y str ● 1994: 1.0. Basic functional programming (lambda methods). ● 2001: 1.6.1 y 2.1. GPL compatible license. ● Python 2.2. All types are unified. All are classes. ● Futurr: Python 3000 (3.0) in 2008.
  • 8. Python is free software ● From Python 2.2, Python Foundation Software License, GPL-compatible. ● All code is property of Python Foundation. ● Python community show a very high activity: – Hundreds of modules/extensions available. – Lots of software available implemented in Python. – Python is the language of 2007 (language TIOBE, Python had biggest increase of usage).
  • 9. Documentation ● Python is very well documented http://docs.python.org ● Tutorial: http://docs.python.org/tut/ ● Language reference: (for language lawyers): http://docs.python.org/ref/ ● Library reference: http://docs.python.org/lib/
  • 10. First session contents ● ¿What's Python? – Brief history – Properties – Documentation ¿Where? ● Introduction to the language – Installation and usage – Practical examples
  • 11. Installation and running In ubuntu, install Python package: $ sudo apt-get install python Very useful to install online documentation: $ sudo apt-get install python-doc
  • 12. Python shell ● Python is an interpreted language. ● Modes: – Interactive – File – Command line – Executable
  • 13. Modo interactivo Just run Python, and add commands and statements in the shell $ python Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type quot;helpquot;, quot;copyrightquot;, quot;creditsquot; or quot;licensequot; for more information. >>> 1+1 2 >>> a = ”hola” >>> a 'hola' >>> print a hola
  • 14. Shell mode help Whith dir () command we get the methods available. >>> dir (a) # With instances >>> dir (list) # With classes With help () command we get the help of a class or instance. >>> help (a) # With instances (no strings) >>> help (list) # With classes
  • 15. Python as a calculator ● Basic types: – Integers – Floats and complex numbers – Strings ● Asign ● _ variable ● Lists. Ranges, asigns by range, operators.
  • 16. Control flow structures ● While. Indentation in Python ● If, If-Elif-Else ● For, range. ● Break, continue, else, pass ● Functions. Definition. ● Classes
  • 17. More flow control structures ● List methods. The list as a queue and as a stack. ● Map, reduce, filter ● List comprehensions ● Del ● Other sequences: tuples. Dictionaries ● Looping ● Conditions, conditions in sequences.
  • 18. Modules ● Modules reference ● Examples: Files api (File objects), http api (urllib2)