Clubes de Ciencia · Summer 2015 · Xalapa, VZ, Mexico

Python 101

Unleash your inner programmer!

Instructors: Nezar Abdennur, Vicente Arbesu

¡Felicidades!

Final presentation

Welcome!

So you've decided to learn Python?

Python is a general-purpose, high-level programming language. It has a design philosophy that emphasizes code readability, which is important because you’ll spend a lot more time reading code than writing it! Python boasts features that make it easy to learn and fast to develop in: elegant syntax, a dynamic typing system, automatic memory management, and support for mutiple programming paradigms. Not sure what all of that means? Well, hopefully you will at the end of our course.

https://xkcd.com/353/

Python has also become increasingly popular in scientific computing and data analysis. There is a flourishing and open-source ecosystem of scientific packages for number crunching, statistical analysis, data visualization, machine learning, image analysis, and more! This is largely thanks to the ease of extending and integrating Python with fast programs written in languages closer to the metal like C and C++.

Material

  • Tools

    If you want to install the tools on your personal laptop.

    1. Python

    We are using the "mini" version of the Anaconda Python distribution, which ships as a package manager utility called conda. Installers for the conda tool can be downloaded from here.

    2. Text editor

    We are using Sublime Text 3, which is also free (in trial mode) and cross-platform.

    3. PyGame

    This can be a pain to install because it is not available on the Python Package Index. Here are recommended approaches depending on your platform:

    $ brew install sdl sdl_image sdl_mixer sdl_ttf portmidi 
    $ pip install hg+http://bitbucket.org/pygame/pygame
    
    • Linux: use your package manager to install the dependencies, and pip to install pygame from the bitbucket repository as above.
  • Day 1

    Getting started

    • Let's talk to python! Scripts vs Interactive Shell.

    A Caffeinated Tour

    Slides

    • Variables
    • Statements and expressions
    • Built-in types
    • Control flow (conditionals, loops)
    • Functions
    • Strings
    • File I/O

    Python 2 or 3?

    Slides

    Exercises

    Slides Code

  • Day 2

    Slides

    Batteries included

    • standard library: os, math, itertools
    • functional tools: map, reduce, filter
    • comprehensions

    Getting classy

    • modules, scope, and namespaces
    • classes and objects

    Building a physics engine with PyGame

  • Day 3

    Python and the web

    • Where to get more batteries: pip and the Python Package Index
    • Web architecture and HTTP
    • Scraping a web page with BeautifulSoup
    • Loteria Game using a web framework (Flask) Code

    Try git!

    • What is version control?
    • Create an account on Github
    • Interactive git tutorial
    • Create a local repository and push your code to a remote repo on Github.
  • Day 4

    Science and data science

    • IPython and the IPython (jupyter) notebook
    • The Scientific Python stack:
      • numpy, scipy, matplotlib, pandas
      • the anaconda distribution
      • the scikits
      • many more!
  • Day 5

    Catch-up and work on final presentation.

Course Wiki

More material and resources will be available on our Github wiki.