COSC 235: Programming and Problem Solving
February 11, 2009

Joseph D. Sloan
sloanjd @ wofford.edu


Odds & Ends from Chapter 2

Programming and Program Language Vocabulary

Metalanguage (used in line completion hint): [optional], ..., <replace>

"_" in names and "_" as a name in the interpreter

Storage and Names

Capturing results and Nesting

x = f(1)
f(x)

or

f(f(1))

Key word vs. Reserved word

def vs. range, note color scheme in IDLE
Table page 30

Expression vs. Statement

Simultaneous assignments and swapping values

Variables in functions are local to functions

Definite Loops

in, range(), and lists, e.g.,

lst = range(10)
for i in lst:
   print i

for i in [9, 11, 19]:
   print i

Future Value Code in Text

Changing number of years
Printing each year
Labeling Output
Adding yearly deposits
Testing the Code!!!
(Change interest periods)

Testing code with boundary values—often easy to judge if correct & a likely point of failure in most code.

Homework


This page was created by Joe Sloan.
It was last modified around: 13 February 2009
Send mail to: sloanjd@wofford.edu