LING 408/508: Programming for Linguists Lecture 19 November 4 th
Administrivia Homework 5 – Does your BMI webserver program work? Homework 6 out today
Python Chapter 3: Computing with Numbers Last time: – Number data types: int, float – Matters for things like division: / 9/5 produces different result from 9/5.0 Basic: Library: module
Python math.sqrt() complex numbers: import cmath
Python range(): produces a list (sequence) – range(n)[0,1,..,n-1] – range(start,n)[start,start+1,..,n-1] – range(start,n,step)[start,start+step,…,last] – last=start+k*step < n – range(n,stop,-step) counts down
Python page 60: factorial.py – automatically converts to type long from int (32 bit 2's complement) – explicit type coercion: 1.float() 2.int() 3.long() 4.complex(r,i) 5.complex(string)
Homework 6 Pick any three of the programming exercises from page – Program them up in python – Submit your code and sample runs all in one pdf file – Due next Monday by midnight