Example and Practice code from Think Python