Python crash course in May
During the Saturdays of May 24th and May 31st, our fellow nerd caedes, who is staying in Amsterdam, is going to give a crash course in the Python programming language.
The Python language is a cross platform tool that allows you to do a lot of things. Many applications are written in it or use little pieces of python code. This is a course for people that already have an idea of what programming is (what is a loop, what is a variable and so on) but you don’t need to know anything about Python.
We think that good courses are the ones that leave a curious flock behind them that can later share newbie tricks and teach each other, and we would like to have at least 10 people joining the course for it to be a success. If we are more, we are going to be able to keep playing with it and learning together even when the course finishes.
If you are interested, drop us a note! slug[AT]lists.riseup.net
And if you still don’t know what a variable is, you still have time to learn before the course! It’s in May!
[...] Python crash course in May [...]
Exercises people did, plus general list of things learned.
Python Tutorial:
http://docs.python.org/tut/tut.html
Python Library Reference:
http://docs.python.org/lib/lib.html
PYTHON WORKSHOP @ SLUG
caedes
PROGRAM 1:
1 – write all numbers from 1 to 1000 in a file (/tmp/numbers), each in a different line
PROGRAM 2
2 – open /tmp/numbers for reading, and print all numbers which are divisible by 5 (%5 == 0)
PROGRAM 3 (MODULE):
3 – taking code from 1 and 2, create a module with the following functions:
write_to_file –> writes numbers from A to B to a file F.
test_division –> reads numbers from file F and, test if they are divisible by a number N, and print them.
SEEN UNTIL NOW:
BASIC TYPES: bool, int, float, list, tuple, dict, str, None
CONTROL FLOW: for, if, while
BASIC FUNCTIONS: open, len, abs, range
HOW MODULES WORK: import module
from module import foo,bar
from module import *
reload(module)
SOME (VERY) USEFUL MODULES: os, math, sys, random
CREATING YOUR OWN PROGRAM:
put your command in a .py file and run it with python.
FUNCTION DEFINITIONS:
def functionname(par1,par2):
do_stuff….
CREATING YOUR OWN MODULE:
put your functions in a .py file, and then you can import it using the file name (without .py).
STRING METHODS:
a.startswith(“blah”)
a.endswith(“blah”)
a.split(“,”)
a.strip()
a.find(“blah”)
a.rfind(“blah”)