Outline for April 3, 2009
Reading: §2.1–2.3
- Software development
- Analyze the problem
- Determine specifications
- Create a design
- Implement the design
- Test/debug the program
- Maintain the program
- Example: program to convert temperature
- Do we go from Fahrenheit to Celsius, Celsius to Fahrenheit, or both?
- Go from Celsius to Fahrenheit
- Steps in the program:
- Ask user for temperature in Celsius
- Convert to Fahrenheit (using well-known formula)
- Print result in Fahrenheit
- Implementation: see tempcvt.py
- Example: sum of first n numbers
- Do we include n or not?
- Begin at 1, add numbers up to and including n
- Steps in the program:
- Initialize total to 0
- Ask user for number
- Count from 1 up to number
- Add each number to total
- Print results
- Implementation:see sum.py
- It doesn’t work—show how to debug it (see
sum2.py for working version)
- Variables
- What they are
- Names, identifiers
- Legal, illegal names
- Reserved words
- Expressions
- Operation, operand
- Operators +, −, *, /, %, **
- Name Errors